I would like to use two different implementations for DAO with Spring testframework.
src.main.java
.businessobjects
\-User.java
.dao
\-IUserDAO.java
.daojpa
\-UserDAO.java
.daohibernate
\-UserDAO.java
Spring test 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:
Called: java.lang.IllegalStateException: The specified bean'userDAO 'name for the bean class [Jpadao.UserDAO] conflicts with existing, incompatible definition of bean name and class [Jpaadao.UserDAO]
I already tried to redefine auto-enlargement using qualifiers, for example:
<bean class="jpaadao.UserDAO">
<qualifier value="jpaa"/>
</bean>
<bean class="jpadao.UserDAO">
<qualifier value="jpa"/>
</bean>
And then in the wiring of the test device using
@Autowired
@Qualifier("jpa")
private IUserDAO userDAO;
but the error persists.
Two questions:
- How to solve this problem using annotation based configuration?
- How can I run tests WITHOUT auto-preparation and annotation?
source
share