title: Spring Batch - dynamic job selection
body: <p>I'm getting familiar with Spring Batch because i believe that is what our project needs to replace our current codebase (to make developments quicker and easier to test).</p>
  
  <p>Our current codebase has the following, important, characteristics:</p>
  
  <ul>
  <li>One codebase - but a lot of batch processes (we reuse code between batch processes)</li>
  <li>Currently, we have multiple main() methods in the codebase and just have different shell scripts to invoke the proper main Class.</li>
  </ul>
  
  <p>I'm looking to tackle the following problem in Spring batch:</p>
  
  <p>I've started a dummy, experimenting project based on the Spring Batch Example: <a href="https://spring.io/guides/gs/batch-processing/" rel="nofollow">https://spring.io/guides/gs/batch-processing/</a> </p>
  
  <p>I would like to keep multiple batch processes (Jobs, i take, if we talk Spring Batch) in the same codebase. However, currently, if i add more Job sin my code, all of them get executed. Even worse, I've added an Application Listener in my SpringBoot main class and it turned out, the Jobs get executed before the ApplicationReadyEvent - this seems quite bad to me, almost like running business logic in a constructor.</p>
  
  <p>My question is:</p>
  
  <ul>
  <li>How can i select which job i want to run (based on command line arguments)</li>
  <li>How can i make sure that the job is started AFTER the ApplicationReadyEvent</li>
  </ul>
  
  <p>Thanks in advance.</p>