我已经在Spring Batch
Web应用程序中开发了几个Spring Boot
作业。为了简化维护,我使用了@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 Task应用程序,并可以使用Spring Cloud Data Flow进行管理。
您应该能够在SpringBoot应用程序中与配置中的EnableTask
一起使用EnableBatchProcessing
。
请参阅演示此方案的SCDF sample。