【发布时间】:2015-03-14 19:24:16
【问题描述】:
我写了以下测试:
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {"classpath:META-INF/dataContext.xml"},classes = Configiuration.class)
@ActiveProfiles("test")
public class CityDaoImplTest {
....
}
当我调用时,我需要使用来自 xml 文件和 java 类 bur 的配置
mvn 测试我在控制台中看到以下内容:
Tests in error:
initializationError(***.CityDaoImplTest): Cannot process locations AND classes for context configuration [ContextConfigurationAttributes@5bb21b69 declaringClass = '***.CityDaoImplTest', classes = '{***.Configiuration}', locations = '{classpath:META-INF/dataContext.xml}', inheritLocations = true, initializers = '{}', inheritInitializers = true, name = [null], contextLoaderClass = 'org.springframework.test.context.ContextLoader']; configure one or the other, but not both.
如何在不重写配置的情况下修复它?
【问题讨论】:
标签: java testing junit configuration spring-test