title: Ways to autowire request scoped bean
body: <p>I just wonder if there is any other way to autowire a request scoped bean. So for now I created a <code>bean</code> in configuration file:</p>
  
  <pre><code>@Bean
  @Scope(value=WebApplicationContext.SCOPE_REQUEST, proxyMode=ScopedProxyMode.DEFAULT)
  public List&lt;String&gt; stringBean(){
      return new ArrayList&lt;String&gt;();
  }
  </code></pre>
  
  <p>So normally I would autowire the <code>applicationContext</code> to use the <code>bean</code>:</p>
  
  <pre><code>@Autowired
  private ApplicationContext context; 
  
  @Override
  public void anyName() {
      List&lt;String&gt; list = (List&lt;String&gt;) getContext().getBean("stringBean");
  }
  </code></pre>
  
  <p>This works totally fine. But I dont like to autowire the context and the need of a cast.  So I tried to autowire the bean directly:</p>
  
  <pre><code>@Autowired
  private List&lt;String&gt; stringBean;
  </code></pre>
  
  <p>I got an exception by startup of the application what is also clear because the bean is not created before a request is started. </p>
  
  <pre><code>org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'stringBean': Scope 'request' 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 thread-bound request found: Are you referring to request attributes outside of an actual web request, or processing a request outside of the originally receiving thread? If you are actually operating within a web request and still receive this message, your code is probably running outside of DispatcherServlet/DispatcherPortlet: In this case, use RequestContextListener or RequestContextFilter to expose the current request.
  </code></pre>
  
  <p>Are there other ways to autowire a request scoped bean?</p>