I have a JPA Repository userRepository (JpaRepositoryFactoryBean). It is configured using annotation with context:component-scan in XML file.
In my test, I'd like to start server:
server = new Server(port); server.setStopAtShutdown(true); WebAppContext webAppContext = new WebAppContext(); webAppContext.setContextPath("/"); webAppContext.setResourceBase("src/main/webapp"); webAppContext.setOverrideDescriptor("src/test/resources/web-test.xml"); server.setHandler(webAppContext); server.start(); In web-test.xml I've defined that context listener should check: classpath:/META-INF/spring/applicationContext.xml,classpath:/META-INF/spring/applicationContext-test.xml
and in applicationContext-test.xml I've defined bean with same id and name as UserRepository.
When I run the server it overriding my TestUserRepository with UserRepository, not the other way round as I would imagine.
2016-01-11 19:22:06,400 INFO [main] o.s.b.f.s.DefaultListableBeanFactory - Overriding bean definition for bean 'userRepository': replacing [Generic bean: class [xxx.yyy.zzz.TestUserRepository]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=true; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null; defined in class path resource [META-INF/spring/applicationContext-test.xml]] with [Root bean: class [org.springframework.data.jpa.repository.support.JpaRepositoryFactoryBean]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null] Can you help?
No comments:
Post a Comment