【问题标题】:How to launch from the command line a spring batch located inside a spring boot project?如何从命令行启动位于 Spring Boot 项目中的 Spring Batch?
【发布时间】:2020-11-12 23:57:01
【问题描述】:

我正在使用 Spring Boot 2.3,其中包含一些 Spring Batch 配置。

目前,如果我想运行 spring 批处理,我使用了以下方法

Spring 批处理作业配置

@Configuration("myJobConf")
@JobReference("myJob")
public class MyJob

application.yml

spring:
  batch:
    job:
      enabled: true
      names: ${JOB_NAME}

当我想从我运行的命令行启动 spring 批处理时

java -jar mySpringBootApplication.jar -DJOB_NAME=myJob

但现在我还需要传递一些作业参数。 我该怎么做?

谢谢

【问题讨论】:

标签: spring-boot spring-batch


【解决方案1】:

但现在我还需要传递一些作业参数。我该怎么做?

您可以将作业参数作为键/值对传递:

java -jar mySpringBootApplication.jar -DJOB_NAME=myJob param1=value1 param2=value2

您可以在参考文档的Batch Applications -> Running from the Command Line 部分找到更多详细信息。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-03-10
    • 1970-01-01
    • 2016-11-04
    • 1970-01-01
    • 2012-11-28
    • 2018-05-29
    相关资源
    最近更新 更多