参数增量器在触发Spring批处理作业时不工作

ie3xauqp  于 2022-12-23  发布在  Spring
关注(0)|答案(1)|浏览(110)

我正在尝试触发一个Spring批处理作业,并希望run.id在定义作业bean时添加RunIdIncrementer后将www.example.com作为作业参数传递,但从日志中看起来参数没有传递。
作业Bean

public Job firstPartyStatsIngestionJob() {

    return jobBuilderFactory.get(TradingCenterJobName.firstPartyStatsIngestionJob.name())
        .incrementer(new RunIdIncrementer())
        .start(getFirstPartyIngestionStep())
        .build();
  }

在这里,我希望在触发作业时传递作业参数run.id,但在日志中,我看到的只是使用以下参数启动:[{}]

[INFO ] 2022-12-16 09:04:07 [main      ] [/] [] JobLauncherApplicationRunner:154 - Running default command line with: []
[INFO ] 2022-12-16 09:04:07 [main      ] [/] [] SimpleJobLauncher:146 - Job: [SimpleJob: [name=firstPartyStatsIngestionJob]] launched with the following parameters: [{}]

关键依赖项和版本
Spring Boot:2.5.12Spring批芯:4.3.5

vmdwslir

vmdwslir1#

尝试使用JobOperator.startNextInstance方法启动作业...
下一个示例(java语言字符串)
如果从命令行运行,则可以指定-next参数...
https://docs.spring.io/spring-batch/docs/current/api/org/springframework/batch/core/launch/support/CommandLineJobRunner.html

相关问题