简体   繁体   English

如何使用 CommandLineJobRunner 调用嵌入在 Spring Boot 应用程序中的 Spring Batch 作业

[英]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.

相关问题 如何使用具有 Java 配置的 CommandLineJobRunner 启动 Spring Batch Job - how to launch Spring Batch Job using CommandLineJobRunner having Java configuration 带有 Spring Batch 的 Spring Boot 应用程序未运行作业 - Spring Boot Application with Spring Batch not Running Jobs Spring Boot如何运行批处理作业 - How Spring Boot run batch jobs 如何按特定顺序运行Spring Batch Jobs(Spring Boot)? - How to run Spring Batch Jobs in certain order (Spring Boot)? 如何使用Spring Boot应用程序更改嵌入式tomcat连接器端口 - How to change embedded tomcat connector port using spring boot application 我们能否在通过Spring Boot应用程序运行的spring批处理中的两个作业之间传递参数 - Can we pass parameters between two jobs in spring batch which run via spring boot application 如何使用Spring和Hibernate为Web应用程序和批处理作业设置事务 - How to set-up transactions for both the web application and batch jobs using Spring and Hibernate 由企业调度程序运行时,Spring Batch CommandLineJobRunner挂起 - Spring Batch CommandLineJobRunner hangs when run by enterprise scheduler Spring Batch CommandLineJobRunner找不到.xml配置文件 - Spring Batch CommandLineJobRunner can't find .xml configuration file 使用 Java 调用 JS 文件,或者如何使用 spring 启动 web 应用程序在浏览器中获得响应 - Invoke JS file using Java or how can I get response in browser using spring boot web application
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM