title: spring autowire 2 beans found exception
body: <p>i have a problem with spring autowire feature which found two beans with the same type, but in fact i only have one bean and the interface that this bean is implementing. </p>
  
  <p>In applicationContext.xml i have these lines:  </p>
  
  <pre><code>&lt;context:component-scan base-package="xxx.vs.services"/&gt;
  &lt;context:component-scan base-package="xxx.vs.dao"/&gt;  
  &lt;context:annotation-config/&gt; 
  
  &lt;bean id="intermedDao" class="xxx.vs.dao.yyy.IntermedDaoImpl" /&gt;
  </code></pre>
  
  <p>and :  </p>
  
  <pre><code>package xxx.vs.dao.abs.yyy;    
  public interface IntermedDao extends GenericDao&lt;Intermed&gt; {
      // methods here
  }
  </code></pre>
  
  <hr>
  
  <pre><code>package xxx.vs.dao.yyy;    
  import org.springframework.stereotype.Repository;
  @Repository
  public class IntermedDaoImpl extends GenericInboundDaoImpl&lt;Intermed&gt; implements IntermedDao {
      // methods here
  }
  </code></pre>
  
  <hr>
  
  <pre><code>package xxx.vs.services.yyy;
  @Service
  @Transactional
  public class IntermedServiceImpl implements IntermedService {
  
      @Autowired
      IntermedDao dao;
  
      public IntermedDao getDao() {
          return dao;
      }
  
      public void setDao(IntermedDao dao) {
          this.dao = dao;
      }    
  }
  </code></pre>
  
  <p>with this config i get:  </p>
  
  <pre><code>java.lang.Exception: java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: 
  org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'intermedServiceImpl': 
  Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: 
  Could not autowire field: xxx.vs.dao.abs.yyy.IntermedDao xxx.vs.services.yyy.IntermedServiceImpl.dao; nested exception is 
  org.springframework.beans.factory.NoSuchBeanDefinitionException:No unique bean of type [xxx.vs.dao.abs.yyy.AgentDao] is defined: expected single matching bean but found 2: [intermedDaoImpl, intermedDao]  
  </code></pre>
  
  <p>does this happens because i scan the packages that contains the interfaces that my DAO`s classes are implementing ?</p>