SpringBatch配置数据库

Spring Batch提供一个任务的仓库实现将任务元数据保存在数据库中,以便监控你的批量处理进程以及其结果.

Spring Batch 数据库引擎支持的有:DB2,Derby, H2, HSQLDB,
MySQL, Oracle, PostgreSQL, SQLServer, and Sybase.

Job-Repository.xml 配置JobRepository到数据库中.

<?xmlversion="1.0" encoding="UTF-8"?>
<beansxmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:batch="http://www.springframework.org/schema/batch"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/batch
http://www.springframework.org/schema/batch/spring-batch-2.1.xsd">
<batch:job-repositoryid="jobRepository"
data-source="dataSource"transaction-manager="transactionManager" />
<beanid="jobLauncher"
class="org.springframework.batch.core.launch.support.SimpleJobLauncher">
<propertyname="jobRepository" ref="jobRepository" />
</bean>
<beanid="dataSource"
class="org.springframework.jdbc.datasource.SingleConnectionDataSource">
<propertyname="driverClassName" value="org.h2.Driver" />
<propertyname="url" value=" jdbc:h2:mem:sbia_ch02;DB_CLOSE_DELAY=-1"/>
<propertyname="username" value="sa" />
<propertyname="password" value="" />
<propertyname="suppressClose" value="true" />
</bean>
<beanid="transactionManager"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<propertyname="dataSource" ref="dataSource" />
</bean>
</beans>

主要是配置这三项内容:
1、batch的命名空间下创建一个jobRepository
2、数据源
3、事务管理器


—–下面有个“顶”字,你懂得O(∩_∩)O哈哈~
—–乐于分享,共同进步!
—–更多文章请看:http://blog.csdn.net/duruiqi_fx


posted on 2016-11-01 21:03  海南一哥  阅读(781)  评论(0编辑  收藏  举报

导航