title: "Step" or "Job" Scope for Spring-Batch beans?
body: <p>I'm using Spring-Batch v3.0.0 for batch imports. There is a <code>StepScope</code> and a <code>JobScope</code>. How can I know which of them is appropriate?</p>
  
  <p>For example, if I define a custom <code>ItemReader</code> or <code>ItemWriter</code> that should use a specific <code>EntityManager</code>, it could look like this:</p>
  
  <pre><code>@Bean
  @Scope("step") //@Scope("job") //custom scope required to inject #jobParameters
  public JpaItemWriter&lt;T&gt; jpaItemWriter(EntityManagerFactory emf) {
      JpaItemWriter&lt;T&gt; writer = new JpaItemWriter&lt;T&gt;();
      writer.setEntityManagerFactory(emf);
      return writer;
  }
  </code></pre>
  
  <p>But which scope is right here? And why?</p>
  
  <p>Execution with <code>step</code> scope works, but I feel the itemWriters should maybe be of <code>job</code> scope so that they are not recreated on every step.</p>
  
  <p>I tried switching <code>step</code> to <code>job</code>, but that throws following error:
   <code>Exception in thread "main" java.lang.IllegalStateException: No Scope registered for scope 'job'</code></p>