只有满足某个条件,我才能在弹簧环境中导入东西吗?
<!-- import ONLY IF current environment is NOT testing -->
<import resource="classpath:context/caching-context.xml" />
Run Code Online (Sandbox Code Playgroud)
目前我通过在我的测试用例中导入完全不同的上下文来做到这一点
@ContextConfiguration(locations = { "classpath*:ApplicationContextTesting.xml" })
Run Code Online (Sandbox Code Playgroud)
但也许有一个更优雅的解决方案,不能为生产和测试维护两个独立的应用程序上下文.
使用Spring配置文件.
<beans profile="not_test">
<import resource="classpath:context/caching-context.xml" />
</beans>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
9443 次 |
| 最近记录: |