【发布时间】:2011-12-26 18:25:28
【问题描述】:
我正在开发 Spring 框架。并做了一个junit类 但我无法正确加载在 junit 类中运行 @Test 方法所需的 xml 文件。就我而言
- xml 文件放在文件夹
WEB-INF下 - junit 测试类在
test/<package_name>下
请建议我在
中声明xml文件的正确方法@ContextConfiguration
@ContextConfiguration( locations={ "classpath:/applicationContext.xml",
"classpath:/applicationDatabaseContext.xml" })
错误:
在允许 TestExecutionListener 时捕获异常 [org.springframework.test.context.support.DependencyInjectionTestExecutionListener@48fa48fa] 准备测试实例 [] java.lang.IllegalStateException: Failed to 加载ApplicationContext
【问题讨论】:
-
您是否使用 maven 进行构建和测试?
-
@user1041110:请添加完整的异常跟踪。在大多数情况下,该异常的原因都写在那里,但您已将其截断。