spring 批处理中 <no-rollback-exception-classes> 标记的 java 配置等效项是什么?
What is the java config equivalent of <no-rollback-exception-classes> tag in spring batch?
我想要 java 以下配置:
`
<step id="step1">
<tasklet>
<chunk reader="itemReader" writer="itemWriter" commit-interval="2"/>
<no-rollback-exception-classes>
<include class="org.springframework.batch.item.validator.ValidationException"/>
</no-rollback-exception-classes>
</tasklet>
</step>
`
<no-rollback-exception-classes>
特别是
谢谢!!!
Java 配置中 no-rollback-exception-classes
的等价物是 org.springframework.batch.core.step.builder.FaultTolerantStepBuilder#noRollback 方法。
在你的情况下,它会是这样的:
@Bean
public Step step(StepBuilderFactory stepBuilderFactory, ItemReader<Integer> itemReader, ItemWriter<Integer> itemWriter) {
return stepBuilderFactory.get("step1")
.<Integer, Integer>chunk(2) // TODO change Integer with your item type
.reader(itemReader)
.writer(itemWriter)
.faultTolerant()
.noRollback(org.springframework.batch.item.validator.ValidationException.class)
.build();
}
希望对您有所帮助。
我想要 java 以下配置:
`
<step id="step1">
<tasklet>
<chunk reader="itemReader" writer="itemWriter" commit-interval="2"/>
<no-rollback-exception-classes>
<include class="org.springframework.batch.item.validator.ValidationException"/>
</no-rollback-exception-classes>
</tasklet>
</step>
`
<no-rollback-exception-classes>
特别是
谢谢!!!
Java 配置中 no-rollback-exception-classes
的等价物是 org.springframework.batch.core.step.builder.FaultTolerantStepBuilder#noRollback 方法。
在你的情况下,它会是这样的:
@Bean
public Step step(StepBuilderFactory stepBuilderFactory, ItemReader<Integer> itemReader, ItemWriter<Integer> itemWriter) {
return stepBuilderFactory.get("step1")
.<Integer, Integer>chunk(2) // TODO change Integer with your item type
.reader(itemReader)
.writer(itemWriter)
.faultTolerant()
.noRollback(org.springframework.batch.item.validator.ValidationException.class)
.build();
}
希望对您有所帮助。