Java 弹簧批+;Spring启动-关闭过程
我是SpringBatch的新手,我不知道如何在作业完成后终止Spring引导过程 在我的批处理配置类中,我配置作业和步骤:Java 弹簧批+;Spring启动-关闭过程,java,spring-boot,spring-batch,Java,Spring Boot,Spring Batch,我是SpringBatch的新手,我不知道如何在作业完成后终止Spring引导过程 在我的批处理配置类中,我配置作业和步骤: @Configuration @EnableBatchProcessing @EnableAutoConfiguration public class BatchConfiguration { @Autowired private JobBuilderFactory jobBuilderFactory; @Autowired private S
@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
@配置
@启用批处理
@启用自动配置
公共类批处理配置{
@自动连线
私人JobBuilderFactory JobBuilderFactory;
@自动连线
私人StepBuilderFactory StepBuilderFactory;
@自动连线
私有MyExecutionListener侦听器;
@自动连线
私有MyTasklet step1Task;
@豆子
公共作业initJob()引发异常{
JobBuilder JobBuilder=jobBuilderFactory.get(“我的作业”).incrementer(new RunIdIncrementer())
.倾听者(倾听者);
FlowBuilder=jobBuilder.flow(step1()).next(step2()).next(step3());
返回builder.build().build();
}
@豆子
公共步骤第1步(){
返回stepBuilderFactory.get(“step1”).tasklet(step1Task.build();
}
//等等
运行spring boot应用程序后,每一步都完成了,我的进程仍在运行。作业执行完成后,我如何停止它?您包括哪些启动程序?如果您的应用程序中没有web组件,则在上下文中的所有作业完成后,它应该自动关闭。@MichaelMinella
spring boot starter-batch
,spring boot starter数据mongodb
和spring boot starter测试
…是因为mongodb starter吗?@MichaelMinella我发现不是!是因为spring boot starter remote shell
,我不知道它在pom.xml中的原因和方式。也许Maven或STS会自动将它包含在我的项目中。真的不知道知道吗!不管怎样,除去依赖关系,进程会正确关闭。谢谢你开车送我找到解决方案。