我的Spring Batch示例从文件读取并写入内存db中的h2。
当流程不引发异常时,一切都会顺利进行。
如果引发SQL异常,则任务执行程序的2个线程保持运行模式,而DestroJavaVM未完成,保持运行模式。
我的工作:
@Bean
public Job importUserJob(JobCompletionNotificationListener listener, Step step1) {
return jobBuilderFactory.get("importUserJob").incrementer(new RunIdIncrementer())
.listener(listener)
.flow(masterStep()).end().build();
}
@Bean
@Qualifier("masterStep")
public Step masterStep() {
return stepBuilderFactory
.get("masterStep")
.partitioner("step1", partitioner)
.step(step1())
.taskExecutor(taskExecutor)
.build();
}
@Bean
public Step step1() {
return stepBuilderFactory.get("step1").<Person, Person>chunk(10)
.reader(personItemReader)
.processor(new PersonItemProcessor())
.writer(writer)
.listener(writerListener)
.faultTolerant()
.skip(DuplicateKeyException.class)
.skipLimit(10)
.build();
}
可能是什么问题?