How to start specific spring batch job with command line


How to start specific spring batch job with command line



I have two configured jobs in my spring boot application. I want to trigger a job manually, using a command in my docker-compose.yml to trigger it. To accomplish this first I disable the batch.job.enabled property in my application.yml:


batch:
initialize-schema: always
job:
enabled: false



I disable it in order to not allow Spring to execute my jobs on application startup.



I'm trying to test my jobs with docker, so in my docker-compose.yml I set this command on my application service to execute when my container is up:


command: java -jar batch-application-1.0-SNAPSHOT.jar -Dspring.batch.job.names=uploadToS3Job date=2018-06-26 type=MyType



This command runs the uploadToS3Job with job parameters date and type.


uploadToS3Job



When I run my application with docker-compose up --build, spring application runs smoothly but the job is not executed, nothing happens, no crash, no nothing.


docker-compose up --build



But if I set this property equal true:


job:
enabled: true



And run docker-compose up again with the same command in my docker-compose.yml, both jobs are executed.


docker-compose up



I really don't know what to do, all I want is execute a specific job with specific job parameters using a command that I will pass in my docker-compose.



What's is wrong with this command:


command: java -jar batch-application-1.0-SNAPSHOT.jar -Dspring.batch.job.names=uploadToS3Job date=2018-06-26 type=MyType



Or what I'm doing wrong?





try --spring.batch.job.names=uploadToS3Job
– Dfor Tye
2 days ago


--spring.batch.job.names=uploadToS3Job





Thank you very much, that's exactly what I needed to do to make it works.
– Mário Sérgio Esteves Alvial
2 days ago





make it as a valid answer plz
– Dfor Tye
2 days ago




1 Answer
1



try



--spring.batch.job.names=uploadToS3Job


--spring.batch.job.names=uploadToS3Job





Can you add some explanation?
– Laurenz Albe
2 days ago





I change my command at docker-compose.yml file from -Dspring.batch.job.names=uploadToS3Job to --spring.batch.job.names=uploadToS3Job and it works. Im using spring boot >2.xx
– Mário Sérgio Esteves Alvial
yesterday






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Comments

Popular posts from this blog

paramiko-expect timeout is happening after executing the command

Opening a url is failing in Swift

Export result set on Dbeaver to CSV