Reputation: 323
I have a simple task which has 2 jobs. When I run the task Job 1 and Job 2 run one after another. How can I configure it in a way so that when I pass the job name only that job runs?
Upvotes: 1
Views: 1592
Reputation: 31745
By default, Spring Boot executes all jobs in the application context at startup (See here). If you want to execute only one job, you need to specify its name using the spring.batch.job.names
property.
In your case, you can add a task argument and specify which job want to run. For example: if your task contains two jobs job1
and job2
, you can add the task argument --spring.batch.job.names=job1
to run only job1
:
Make sure to add --
to the key. The command that will be executed by SCDF server should be something like:
2018-09-10 12:23:45.932 INFO 57560 --- [nio-9393-exec-1] o.s.c.d.spi.local.LocalTaskLauncher : Command to be executed: java -jar myjob.jar --spring.batch.job.names=job1 --spring.cloud.task.executionid=1
With this argument, only job1
should be executed.
Hope this helps.
Upvotes: 2