[英]How to invoke Spring Batch Jobs embedded in a Spring Boot Application using CommandLineJobRunner
I have a spring boot application which has 2 modules to it.我有一个 Spring Boot 应用程序,它有 2 个模块。 First is a web module that exposes a rest API which allows users to some data into the application.
首先是一个 web 模块,它公开了一个 rest API,它允许用户将一些数据导入到应用程序中。 Second module is set of batch jobs that act on these configurations and perform background processing.
第二个模块是一组批处理作业,它们作用于这些配置并执行后台处理。
I was able to create both REST API and batch jobs in the application and as a starting point, I used a REST end point to kickoff my batch jobs using JobLauncher.我能够在应用程序中创建 REST API 和批处理作业,作为起点,我使用 REST 端点使用 JobLauncher 启动我的批处理作业。
My next task is to package the application and deploy the web application to expose REST endpoints and also create shell scripts to kick off the batch jobs using an enterprise scheduler.我的下一个任务是打包应用程序并部署 Web 应用程序以公开 REST 端点,并创建 shell 脚本以使用企业调度程序启动批处理作业。
I am Using Maven and spring-boot-maven-plugin to build the executable jar.我正在使用 Maven 和 spring-boot-maven-plugin 来构建可执行 jar。 When I execute
java -jar myApp.jar
REST APIs are getting exposed however, when I try to run the batch jobs by executing java -cp myApp.jar org.springframework.batch.core.launch.support.CommandLineJobRunner com.example.myJobConfig job1 runDate=2020-02-29
但是,当我执行
java -jar myApp.jar
REST API 时,当我尝试通过执行java -cp myApp.jar org.springframework.batch.core.launch.support.CommandLineJobRunner com.example.myJobConfig job1 runDate=2020-02-29
来运行批处理作业时java -cp myApp.jar org.springframework.batch.core.launch.support.CommandLineJobRunner com.example.myJobConfig job1 runDate=2020-02-29
I get the following error Error: Could not find or load main class org.springframework.batch.core.launch.support.CommandLineJobRunner我收到以下错误错误:无法找到或加载主类 org.springframework.batch.core.launch.support.CommandLineJobRunner
I am looking for help on how I can have both web app and batch jobs in a single application and launch the batch jobs using a shell script.我正在寻求有关如何在单个应用程序中同时拥有 Web 应用程序和批处理作业并使用 shell 脚本启动批处理作业的帮助。
I am Using Maven and spring-boot-maven-plugin to build the executable jar
我正在使用 Maven 和 spring-boot-maven-plugin 来构建可执行的 jar
In this case, you can run your job on the command line using:在这种情况下,您可以使用以下命令在命令行上运行您的作业:
java -jar myApp.jar --spring.batch.job.names=job1 runDate=2020-02-29
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.