【发布时间】:2020-02-10 15:59:25
【问题描述】:
我在Spring Boot Web 应用程序中开发了几个Spring Batch 工作。为了便于维护,我使用了@EnableBatchProcessing(modular = true),如下所示:
@Configuration
@EnableBatchProcessing(modular = true)
public class BatchConfiguration {
@Bean
@ConditionalOnProperty(value="first.batch.enabled", havingValue = "true")
public ApplicationContextFactory firstJobs() {
return new GenericApplicationContextFactory(FirstModule.class);
}
@Bean
@ConditionalOnProperty(value="second.batch.enabled", havingValue = "true")
public ApplicationContextFactory secondJobs() {
return new GenericApplicationContextFactory(SecondModule.class);
}
...
}
我有@Configuration 类,每个Job 分别在模块的基本目录中定义一个。一切正常,但现在我想设置Spring Cloud Dataflow UI 以对我的Jobs 进行一些基本监控。
问题是,当我尝试将@EnableTask 注释添加到此类BatchConfiguration 时,Spring 没有将作业执行与任务执行相关联。它仅在我运行测试时才有效(@SpringBatchTest)。
我也尝试将@EnableTask 注释添加到FirstJobConfiguration 类,并将其添加到BatchConfiguration 和First|JobConfiguration,但没有任何效果。我也浏览了官方文档,但一无所获。
是否可以将Spring Cloud Task 与模块化Spring Batch 一起使用?
谢谢。
【问题讨论】:
标签: spring-batch spring-cloud-dataflow spring-cloud-task