title: why does annotate class as @Service do not create bean?
body: <p>I has class like this:</p>
  
  <pre><code>@Service("userDetailsService") 
  public class MyUserDetailsService implements UserDetailsService {
      ...
  </code></pre>
  
  <p>and trying to do:</p>
  
  <pre><code>&lt;authentication-manager&gt;
      &lt;authentication-provider user-service-ref="userDetailsService"&gt;
      &lt;/authentication-provider&gt;
  &lt;/authentication-manager&gt;
  </code></pre>
  
  <p>and I got followin errors:</p>
  
  <blockquote>
    <p>Cannot resolve reference to bean 'userDetailsService' while setting
    bean property 'userDetailsService'; nested exception is
    org.springframework.beans.factory.NoSuchBeanDefinitionException: No
    bean named 'userDetailsService' is defined</p>
  </blockquote>
  
  <p>Is it really necessary to declare bean? In that case like this:</p>
  
  <pre><code>&lt;beans:bean id="myUserDetailsService" class="my.package.services.MyUserDetailsService" /&gt;
  </code></pre>
  
  <p><strong>EDIT</strong></p>
  
  <p>Here is my <code>security.xml</code> file:</p>
  
  <pre><code>&lt;beans:beans xmlns="http://www.springframework.org/schema/security"
      xmlns:beans="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:jdbc="http://www.springframework.org/schema/jdbc" 
      xmlns:context="http://www.springframework.org/schema/context"
      xsi:schemaLocation="http://www.springframework.org/schema/beans
             http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
             http://www.springframework.org/schema/jdbc
             http://www.springframework.org/schema/jdbc/spring-jdbc-3.0.xsd
             http://www.springframework.org/schema/security
             http://www.springframework.org/schema/security/spring-security-3.0.xsd"&gt;
  
      &lt;http&gt;
          &lt;form-login login-page="/login/"
              authentication-failure-url="/fail/" /&gt;
          &lt;logout logout-success-url="/" /&gt;
      &lt;/http&gt;
  
      &lt;context:annotation-config /&gt;
      &lt;context:component-scan base-package="my.package" /&gt;
  
      &lt;authentication-manager&gt;
          &lt;authentication-provider user-service-ref="myUserDetailsService"&gt;
              &lt;!-- &lt;password-encoder hash="md5" /&gt; --&gt;
          &lt;/authentication-provider&gt;
      &lt;/authentication-manager&gt;
  
  &lt;/beans:beans&gt;
  </code></pre>
  
  <p>which cause:</p>
  
  <blockquote>
    <p>The matching wildcard is strict, but no declaration can be found for
    element 'context:annotation-config'.</p>
  </blockquote>