(转)@ContextConfiguration注解说明
                                                            生活随笔
收集整理的這篇文章主要介紹了
                                (转)@ContextConfiguration注解说明
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.                        
                                場景:學(xué)習(xí)spring實戰(zhàn)中相關(guān)的單元測試
1 正常使用
@ContextConfiguration Spring整合JUnit4測試時,使用注解引入多個配置文件
1.1 單個文件
@ContextConfiguration(locations="../applicationContext.xml")
@ContextConfiguration(classes = SimpleConfiguration.class)
1.2 多個文件
可用{}
@ContextConfiguration(locations = { "classpath*:/spring1.xml", "classpath*:/spring2.xml" })
1.3 默認不寫
可以根據(jù)測試的類名,去找到與之對應(yīng)的配置文件。
?異常情況:
異常信息
四月 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.
?
?
1
?
轉(zhuǎn)載于:https://www.cnblogs.com/lixuwu/p/6697537.html
總結(jié)
以上是生活随笔為你收集整理的(转)@ContextConfiguration注解说明的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
 
                            
                        - 上一篇: 做弓形虫检查大概需要多少钱啊
- 下一篇: 烟雨江湖天罡剑指决怎么学?
