title: Spring Batch with modular=true and GenericApplicationContextFactory is cumbersome
body: <p>I'm using Spring Batch with <code>@EnableBatchProcessing(modular = true)</code></p>
  
  <p>The problem is that in this mode you have to explicitly declare which beans to initialize (i.e which classes Spring needs to scan)</p>
  
  <p>Here's an exmaple:</p>
  
  <pre><code>@Configuration
  @EnableBatchProcessing(modular = true)
  public class ModularJobsConfig {
      @Autowired
      private AutomaticJobRegistrar registrar;
  
      @PostConstruct
      public void initialize() {
          registrar.addApplicationContextFactory(new GenericApplicationContextFactory(
                  SomeJobConfig.class,
                  SomeJobTasklet.class,
                  SomeClassToDefineTaskExecutor.class
                  SomeClassToRunTheJob.class));
      }
  }
  </code></pre>
  
  <p>I can imagine that by the time I'll have several jobs, this configuration class will be bloated. How can I automate this?</p>
  
  <p>It is worth mentioning that each job has its own package (e.g <code>com.example.jobs.&lt;job_name&gt;</code>) + they are defined in different maven-modules but I think it's irrelevant. </p>
  
  <p><strong>Further Clarification</strong></p>
  
  <p>I have a <code>core</code> module which contains the configuration above. Every job is defined in a separate maven module and it's been registered as a maven dependency in <code>core</code>.</p>
  
  <p>Mainly for preventing naming clash, I'm using <code>@EnableBatchProcessing(modular = true)</code> and I'm registering the jobs with <code>AutomaticJobRegistrar</code> as you can see in the example code above.</p>
  
  <p>Ideally, I'd like Spring to scan the maven dependency and to do it for me (i.e. defining <code>GenericApplicationContextFactory</code>)</p>
  
  <p>Currently, it's cumbersome to add manually each and every class (in the example above: <code>SomeJobConfig.class</code>, <code>SomeJobTasklet.class</code> etc)</p>
  
  <p>As a counter example, if I didn't use <code>modular=true</code> I could let Spring Batch to load all beans on its own, but then I'd have to make sure methods names are unique across all the modules.</p>