学无先后,达者为师

网站首页 编程语言 正文

spring junit 做单元测试,报 Failed to load ApplicationContext 错误。

作者:dearLHB 更新时间: 2022-03-14 编程语言

spring junit 做单元测试,报 Failed to load ApplicationContext 错误。

 

查找了好一会,最后发现。

@ContextConfiguration(locations = { "classpath:spring*.xml", "classpath:struts.xml", "classpath:spring-hibernate.xml" })

改成

@ContextConfiguration(locations = { "classpath*:spring*.xml", "classpath*:struts.xml", "classpath*:spring-hibernate.xml" })

就好了。

 

可能是因为项目里引用了其他项目,有相同名称的spring配置文件导致的。在classpath后加上*就可以了。

原文链接:https://blog.csdn.net/dearLHB/article/details/46290983

栏目分类
最近更新