我在 springBatch 作业中使用 checkListener 和 readListener 作为我用来学习 springbatch 的示例。但是当我运行作业时,chunkListener 不运行,只有 readListener 与作业一起运行。
personChunkListener.java:
package sb.dbToxml;
import javax.batch.api.chunk.listener.ChunkListener;
public class PersonChunkListener implements ChunkListener
{
@Override
public void afterChunk() throws Exception
{
System.out.println("after chunk ....***************");
}
@Override
public void beforeChunk() throws Exception
{
System.out.println("before chunk ....***************");
}
@Override
public void onError(Exception arg0) throws Exception
{
// TODO Auto-generated method stub
}
}
this is the configuration xml file for spring batch context
spring-batch-context.xml :
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.2.xsd">
<import resource="../jobs/jobPerson.xml" />
<import resource="../config/spring-datasource.xml" />
<!-- <context:annotation-config /> <tx:annotation-driven transaction-manager="transactionManager"/>a
PlatformTransactionManager is still required -->
<!-- JobRepository and JobLauncher are configuration/setup classes -->
<bean id="jobRepository"
class="org.springframework.batch.core.repository.support.JobRepositoryFactoryBean">
<property name="dataSource" ref="dataSourceBatch" />
<property name="transactionManager" ref="transactionManager" />
<property name="databaseType" value="oracle" />
</bean>
BIG阳
相关分类