我正在尝试触发一个春季批处理作业并期望运行。id作为一个作业参数,在定义作业bean时添加RunIdIncrementer后传递。但是从日志来看,参数似乎没有被传递。
工作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-batch-core: 4.3.5
尝试使用JobOperator.startNextInstance
方法启动作业…
https://docs.spring.io/spring-batch/docs/current/api/org/springframework/batch/core/launch/JobOperator.html startNextInstance(以)
如果从命令行运行,可以指定-next参数…
https://docs.spring.io/spring-batch/docs/current/api/org/springframework/batch/core/launch/support/CommandLineJobRunner.html