Run Spring Batch (JSR-352) application on Spring Boot

我是研究僧i 提交于 2019-12-24 18:23:18

问题


I have a simple Spring Batch application complying with JSR-352.

I need to deploy this as a managed Task on Spring Cloud Data Flow server. As far as I know - to be able to deploy this as a Task I need to convert this application as a Spring Boot app.

I have tried to add Spring Boot dependencies and Main class however it is not running the Batch job when I start the app.

Main Class

@SpringBootConfiguration
@EnableAutoConfiguration
@EnableBatchProcessing
public class Application {

    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
    }

}

Batch File created at

META-INF/batch-jobs/myjob.xml

It works when I use JobOperator in the main class to start the job (without Spring Boot).

What am I missing to run this as a Spring Boot app?


回答1:


You're missing @EnableTask annotation. With that, your batch-job will be run as a short-lived application. In other words, the application will run as long as the business logic in your XML needs to run, and it will gracefully shut down and free-up resources.

Please clone and try out the Spring Cloud Task samples [see: BatchJobApplication]. All of them should work as-is in SCDF as well.



来源:https://stackoverflow.com/questions/56343203/run-spring-batch-jsr-352-application-on-spring-boot

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!