I have override jobLauncher()
in BatchConfig in my SpringBatchapplication as follow:
@Bean
public JobLauncher jobLauncher() throws SQLException {
SimpleJobLauncher jobLauncher = new SimpleJobLauncher() {
JobParameters params = new JobParametersBuilder()
.addString("param1", "ABC")
.addLong("time",System.currentTimeMillis())
.toJobParameters();
@Override
public JobExecution run(Job job, JobParameters jobParameters) throws JobExecutionAlreadyRunningException, JobRestartException, JobInstanceAlreadyCompleteException, JobParametersInvalidException {
return super.run(job, params);
}
};
jobLauncher.setJobRepository(getJobRepository());
return jobLauncher;
}
However, now I want param1
to be passed in as a command line argument. Is this possible while overriding jobLauncher()
at the same time?