我如何将Spring Cloud Task与模块化Spring Batch作业一起使用?

问题描述 投票:0回答:1

我已经在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类中,并将其同时添加到BatchConfigurationFirst|JobConfiguration中,但无效。我也查看了官方文档,但一无所获。

是否可以将Spring Cloud Task与模块化Spring Batch一起使用?

谢谢。

spring-batch spring-cloud-dataflow spring-cloud-task
1个回答
0
投票

Spring Batch应用程序可以转换为Spring Cloud Task应用程序,并可以使用Spring Cloud Data Flow进行管理。

您应该能够在SpringBoot应用程序中与配置中的EnableTask一起使用EnableBatchProcessing

请参阅演示此方案的SCDF sample

© www.soinside.com 2019 - 2024. All rights reserved.