跑批利器--往数据库里配置SpringBatch

        

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


       Spring Batch 数据库引擎支持的有:DB2,Derby, H2, HSQLDB,

MySQL, Oracle, PostgreSQL, SQLServer, and Sybase.你所需要做的就是为SpringBatch创建一个数据库并执行正确的SQL脚本.


         接下来的代码实例将是展示如何配置JobRepository到数据库中.

      

 

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">

data-source="dataSource"transaction-manager="transactionManager" />

class="org.springframework.batch.core.launch.support.SimpleJobLauncher">

class="org.springframework.jdbc.datasource.SingleConnectionDataSource">

class="org.springframework.jdbc.datasource.DataSourceTransactionManager">

 


        上述示例中,Job-Repository xml元素在batch的命名空间下创建一个jobRepository.为了能够正确运行,这个任务仓库需要一个数据源和事务管理器的支持.主要是配置这三项内容.

 

 

 

 

 

你可能感兴趣的:(架构设计)