title: Spring Security: autowire ProviderManager
body: <p>I am trying to programatically validate a user login/pass using Spring Security, so I need to have access to the <code>ProviderManager</code>.  I would like it to be automatically injected into my <code>@Controller</code>.</p>
  
  <p>My code looks like:</p>
  
  <pre><code>import org.springframework.security.authentication.ProviderManager;
  
  // ...
  
  @Controller
  public class MyController {
  
      @Autowired
      private ProviderManager authenticationManager;
  </code></pre>
  
  <p>But when I try to run the application I get this error message:</p>
  
  <pre><code>No unique bean of type [org.springframework.security.authentication.ProviderManager] is defined: 
  expected single matching bean but found 2: 
  [org.springframework.security.authentication.ProviderManager#0, org.springframework.security.authenticationManager]
  </code></pre>
  
  <p>What could be the cause or how could I solve it?</p>
  
  <p>I am using Spring Security 3.0.0-RC1 with Spring 3.0.1, and I've not defined any <code>ProviderManager</code> bean. I've successfully used:</p>
  
  <pre><code>@Resource
  private ProviderManager authenticationManager;
  </code></pre>
  
  <p>in other projects, but <code>javax.annotation.Resource</code> is not supported in GAE.</p>