我是Spring Batch的新手,我无法弄清楚如何在作业完成后终止Spring Boot进程。
在我的 BatchConfiguration 类中,我配置作业和步骤:
@Configuration
@EnableBatchProcessing
@EnableAutoConfiguration
public class BatchConfiguration {
@Autowired
private JobBuilderFactory jobBuilderFactory;
@Autowired
private StepBuilderFactory stepBuilderFactory;
@Autowired
private MyExecutionListener listener;
@Autowired
private MyTasklet step1Task;
@Bean
public Job initJob() throws Exception {
JobBuilder jobBuilder = jobBuilderFactory.get("my-job").incrementer(new RunIdIncrementer())
.listener(listener);
FlowBuilder<FlowJobBuilder> builder = jobBuilder.flow(step1()).next(step2()).next(step3());
return builder.build().build();
}
@Bean
public Step step1() {
return stepBuilderFactory.get("step1").tasklet(step1Task).build();
}
// and so on
运行spring boot app后,每一步都完成了,我仍然可以运行该进程。如何在作业执行完成后停止它?