gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-02 08:48:20 24 4
gpt4 key购买 nike

我有一个 Spring Boot 应用程序,其中有 2 个模块。首先是一个 Web 模块,它公开了一个 REST API,允许用户将一些数据输入到应用程序中。第二个模块是一组批处理作业,它们作用于这些配置并执行后台处理。

我能够在应用程序中创建 REST API 和批处理作业,并且作为起点,我使用 REST 端点通过 JobLauncher 启动批处理作业。

我的下一个任务是打包应用程序并部署 Web 应用程序以公开 REST 端点,并创建 shell 脚本以使用企业调度程序启动批处理作业。

我正在使用 Maven 和 spring-boot-maven-plugin 来构建可执行 jar。当我执行时然而,当我尝试通过执行来运行批处理作业时,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

我收到以下错误错误:无法找到或加载主类 org.springframework.batch.core.launch.support.CommandLineJobRunner

我正在寻求帮助,了解如何在单个应用程序中同时拥有 Web 应用程序和批处理作业,并使用 shell 脚本启动批处理作业。

最佳答案

I am Using Maven and spring-boot-maven-plugin to build the executable jar

在这种情况下,您可以使用以下命令在命令行上运行作业:

java -jar myApp.jar --spring.batch.job.names=job1 runDate=2020-02-29

关于java - 如何使用 CommandLineJobRunner 调用嵌入在 Spring Boot 应用程序中的 Spring Batch 作业,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60941090/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com