title: Spring Test Framework and annotation-based autowiring Problem
body: <p>I would like to use two different implementations for a DAO with Spring's testframework. </p>
  
  <p>src.main.java</p>
  
  <pre><code>.businessobjects
     \-User.java
  .dao
     \-IUserDAO.java
  .daojpa
     \-UserDAO.java
  .daohibernate
     \-UserDAO.java
  </code></pre>
  
  <p>The spring testcase in:</p>
  
  <p>src.test.java.base:</p>
  
  <pre><code>package base;
  
  import org.junit.runner.RunWith;
  import org.springframework.test.context.ContextConfiguration;
  import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
  import org.springframework.transaction.annotation.Transactional;
  
  @RunWith(SpringJUnit4ClassRunner.class)
  @ContextConfiguration("/hibernate-beans.xml")
  @Transactional
  public abstract class SpringTestCase {}
  </code></pre>
  
  <p>And here is the error:</p>
  
  <blockquote>
    <p>Caused by:
    java.lang.IllegalStateException:
    Annotation-specified bean name
    'userDAO' for bean class
    [jpadao.UserDAO]
    conflicts with existing,
    non-compatible bean definition of same
    name and class
    [jpaadao.UserDAO]</p>
  </blockquote>
  
  <p>I have already tried to override the autowiring by using qualifiers, e.g.:</p>
  
  <pre><code>&lt;bean class="jpaadao.UserDAO"&gt;
      &lt;qualifier value="jpaa"/&gt;
  &lt;/bean&gt;
  &lt;bean class="jpadao.UserDAO"&gt;
      &lt;qualifier value="jpa"/&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p>And then in the testcase wiring with</p>
  
  <pre><code>@Autowired
  @Qualifier("jpa")
  private IUserDAO userDAO;
  </code></pre>
  
  <p>but the error persists.</p>
  
  <p>Two questions:</p>
  
  <ol>
  <li>How can this problem be solved with annotation based configuration?</li>
  <li>How can I run tests <em>WITHOUT</em> autowiring and annotations?</li>
  </ol>