Hi
I would like to use two different implementations for a DAO with Spring's testframework.
src.main.java
.businessobjects
\-User.java
.dao
\-IUserDAO.java
.daojpa
\-UserDAO.java
.daohibernate
\-UserDAO.java
The spring testcase in:
src.test.java.base:
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 {}
And here is the error:
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]
I have already tried to override the autowiring by using qualifiers, e.g.:
<bean class="jpaadao.UserDAO">
<qualifier value="jpaa"/>
</bean>
<bean class="jpadao.UserDAO">
<qualifier value="jpa"/>
</bean>
And then in the testcase wiring with
@Autowired
@Qualifier("jpa")
private IUserDAO userDAO;
but the error persists.
Two questions:
- How can this problem be solved with annotation based configuration?
- How can I run tests WITHOUT autowiring and annotations?