1
votes

I'm working with spring boot 2.3 and I've some spring batch configurations inside it.

Currently if I want to run a spring batch process I've used the following approach

Spring batch job configuration

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

application.yml

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

And when I want to launch the spring batch process from the command line I run

java -jar mySpringBootApplication.jar -DJOB_NAME=myJob

But now I need to pass some job parameters also. How can I do that?

Thank you

1
I added an answer. Does it help?Mahmoud Ben Hassine
That exactly what I need. I've searched in the spring batch documentation, but not in the spring boot one. Thank youGavi

1 Answers

2
votes

But now I need to pass some job parameters also. How can I do that?

You can pass job parameters as key/value pairs:

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

You can find more details in the Batch Applications -> Running from the Command Line section of the reference documentation.