场景:学习spring实战中相关的单元测试spring
@ContextConfiguration Spring整合JUnit4测试时,使用注解引入多个配置文件app
@ContextConfiguration(locations="../applicationContext.xml")单元测试
@ContextConfiguration(classes = SimpleConfiguration.class)学习
可用{}测试
@ContextConfiguration(locations = { "classpath*:/spring1.xml", "classpath*:/spring2.xml" })spa
能够根据测试的类名,去找到与之对应的配置文件。code
异常状况:xml
异常信息blog
四月 12, 2017 9:38:10 上午 org.springframework.test.context.support.AbstractContextLoader generateDefaultLocations 信息: Could not detect default resource locations for test class [soundsystem.CNamespaceValueTest]: class path resource [soundsystem/CNamespaceValueTest-context.xml] does not exist 四月 12, 2017 9:38:10 上午 org.springframework.test.context.support.AnnotationConfigContextLoaderUtils detectDefaultConfigurationClasses 信息: Could not detect default configuration classes for test class [soundsystem.CNamespaceValueTest]: CNamespaceValueTest does not declare any static, non-private, non-final, inner classes annotated with @Configuration.
1it