Spring Batch Java Config:出现异常时跳过步骤,然后转到下一步 [英] Spring Batch Java Config: Skip step when exception and go to next steps
本文介绍了Spring Batch Java Config:出现异常时跳过步骤,然后转到下一步的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
例如我在工作中有3个步骤(类似于第1步):
e.g. i have 3 Steps in Job (similar to Step1):
@Autowired
private StepBuilderFactory stepBuilderFactory;
@Bean
public Step step1() {
return stepBuilderFactory
.get("step1")
.<String, String> chunk(1)
.reader(reader())
.processor(processor())
.writer(writer())
.build();
}
即使在步骤1中出现异常后,如何继续执行步骤2和3?我的意思是使用Java进行配置.
How go to Step 2 and 3 even after exception in Step 1? I mean configuration in Java.
推荐答案
以下是创建流时如何配置它的示例.这应该与直接通过作业生成器进行配置类似:
Here is an example on how to configure it when creating a flow. That should be similar to configure it directly with the job builder:
return new FlowBuilder<SimpleFlow>("name")
.start(step1) //
.next(step2).on(ExitStatus.FAILED.getExitCode()).to(errorStep)
.from(step2).on(ALL_PATTERN).to(step3)
.build();
这篇关于Spring Batch Java Config:出现异常时跳过步骤,然后转到下一步的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文