小编Lal*_*yal的帖子

Junit类 - 无法加载ApplicationContext

我正在研究Spring Framework.并制作了一个junit类,但我无法正确加载在junit类中运行@Test方法所需的xml文件.就我而言

  • xml文件放在文件夹下 WEB-INF
  • junit测试类是在 test/<package_name>

请建议我正确声明xml文件的方法

@ContextConfiguration

@ContextConfiguration( locations={ "classpath:/applicationContext.xml",
        "classpath:/applicationDatabaseContext.xml" })
Run Code Online (Sandbox Code Playgroud)

错误:

允许TestExecutionListener [org.springframework.test.context.support.DependencyInjectionTestExecutionListener@48fa48fa]准备测试实例[]时出现异常java.lang.IllegalStateException:无法加载ApplicationContext

java junit spring

4
推荐指数
1
解决办法
2万
查看次数

标签 统计

java ×1

junit ×1

spring ×1