I was wondering if there's a way to enable/disable all of defined spring-batch jobs programmatically? For instance when I deploy my app, the database is empty and at that moment my jobs are running and throwing exceptions. I would like to have the jobs disabled until some data is populated in the database (until certain tables appear). Is this possible?
Have you take a look at this question? How Spring Boot run batch jobs
You can disable the job at startup by adding spring.batch.job.enabled=false
to application.properties
file.
Then you can use the JobLauncher to run the job when your database is initialised.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With