title: Spring Boot & Spring Batch auto wiring
body: <p>I'm trying to get me head around Spring Boot's auto wiring for Spring Batch.  In the example in the Spring docs, there are a number of parameters being passed in the constructor to some beans.</p>
  
  <p>The example works, but if I try to create another job using the identical configuration (naming it <code>importUserJob2</code>), I get a non-unique bean exception - the error reports there are 2 step beans.</p>
  
  <pre><code>@Bean
      public Job importUserJob(JobBuilderFactory jobs, Step s1, JobExecutionListener listener) {
          return jobs.get("importUserJob")
                  .incrementer(new RunIdIncrementer())
                  .listener(listener)
                  .flow(s1)
                  .end()
                  .build();
      }
  </code></pre>
  
  <p>What does the constructor here mean when used with parameters (I can't see where these parameters are supplied) and where are these beans being created?  How do I create 2 jobs?</p>
  
  <p>EDIT: here are the 2 jobs, 2 steps and the exception I get.</p>
  
  <pre><code>@Bean
  public Job helloJob(JobBuilderFactory jobs, Step s1, JobExecutionListener listener) {
      return jobs.get("helloJob")
              .incrementer(new RunIdIncrementer())
              .listener(listener)
              .flow(s1)
              .end()
              .build();
  }
  
  @Bean
  public Step step1(StepBuilderFactory stepBuilderFactory) {
      return stepBuilderFactory.get("step1")
              .tasklet(helloTasklet())
              .build();
  }
  
  
  @Bean
  public Job otherJob(JobBuilderFactory jobs, Step s1, JobExecutionListener listener) {
      return jobs.get("otherJob")
              .incrementer(new RunIdIncrementer())
              .listener(listener)
              .flow(s1)
              .end()
              .build();
  }
  
  @Bean
  public Step step2(StepBuilderFactory stepBuilderFactory, ItemReader&lt;MyReadItem&gt; reader,
                          ItemWriter&lt; MyReadItem &gt; writer) {
      return stepBuilderFactory.get("step2")
              .&lt; MyReadItem, MyReadItem &gt; chunk(10)
              .reader(reader)
              .writer(writer)
              .build();
  }
  </code></pre>
  
  <p>And the exception:</p>
  
  <pre><code>nested exception is org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type [org.springframework.batch.core.Step] is defined: expected single matching bean but found 2: step1,step2
  </code></pre>
  
  <p>What creates <code>Step s1</code>?  Am I right in thinking that Spring just looks for any bean that is the correct type (<code>Step</code>), but there are 2 found?  Do I need to qualify the steps when they're created to ensure the correct one is injected??</p>