title: spring batch: scope("step") failed
body: <p>I could use <code>scope=&quot;step&quot;</code> in xml configuration without any issue, but if use it as annotation as below
  . it throws the following error</p>
  <blockquote>
  <p>Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'step1' defined in class path resource [BatchConfiguration.class]: Unsatisfied dependency expressed through constructor argument with index 1 of type [org.springframework.batch.item.ItemReader]: : Error creating bean with name 'reader': Scope 'step' is not active for the current thread; consider defining a scoped proxy for this bean if you intend to refer to it from a singleton; nested exception is java.lang.IllegalStateException: No context holder available for step scope; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'reader': Scope 'step' is not active for the current thread; consider defining a scoped proxy for this bean if you intend to refer to it from a singleton; nested exception is java.lang.IllegalStateException: No context holder available for step scope</p>
  </blockquote>
  <p>The main point is:</p>
  <p>Scope 'step' is not active for the current thread;</p>
  <p>what's the root cause?</p>
  <pre><code>public class BatchConfiguration {
  
      @Bean
      @Scope(&quot;step&quot;)
      public ItemReader&lt;Source&gt; reader(@Value(&quot;#{jobParameters['fileName']}&quot;) String fileName) {
          System.out.println(&quot;*****************************&quot;);
          System.out.println(&quot;read file of &quot;+fileName);
          System.out.println(&quot;*****************************&quot;);
          FlatFileItemReader&lt;Source&gt; reader = new FlatFileItemReader&lt;Source&gt;();
  
          reader.setResource(new FileSystemResource(fileName));
          reader.setLineMapper(new DefaultLineMapper&lt;Source&gt;() {{
              setLineTokenizer(new DelimitedLineTokenizer() {{
                  setNames(new String[] { &quot;firstName&quot;, &quot;lastName&quot; });
              }});
              setFieldSetMapper(new BeanWrapperFieldSetMapper&lt;Source&gt;() {{
                  setTargetType(Source.class);
              }});
          }});
          return reader;
      }
  </code></pre>