0

I have a Spring Boot application. When my application starts up I have to seed the database. After that I don't need to seed it again. As of now, I'm doing this using Spring Batch. But the batch kicks off any time I start my app (dev-test-redeploy).

Is there a way for me to tell Spring Batch to do nothing based on a variable? I know how to get my environment parameters anywhere they need to be, I just don't know where to put it in my Spring Batch setup.

Any help is greatly appreciated.

Squashman
  • 13,649
  • 5
  • 27
  • 36
Black Dynamite
  • 4,067
  • 5
  • 40
  • 75

1 Answers1

0

Not sure what your full setup is, but is it possible to check the database (do a simple count) to see if the data is already there in your Step/TaskLet implementation to not process the items at all or your reader/writer to just skip the items?

If you really want to use a configuration property, you may want to take a look at applying a @ConditionalOnProperty to your batch configuration. (Although using a property is more prone to human error, as you need to remember to toggle the parameter the second time you start the app).