java.lang.IllegalStateException: Failed to load ApplicationContext
at org.springframework.test.context.CacheAwareContextLoaderDelegate.loadContext(CacheAwareContextLoaderDelegate.java:99)
我出现这个报错的原因是因为mybatis的mapper.xml文件里面有错误
或者使用的mybatis-generator-core-1.3.2的版本更新为mybatis-generator-core-1.3.5并且把generatorConfig.xml的生成文件目录配置成和实际ssm工程的包路径一致就好了
///下面是转载别人碰到相同的错误
spring junit 做单元测试,报 Failed to load ApplicationContext 错误。
查找了好一会,最后发现。@ContextConfiguration(locations = { "classpath:/spring/applicationContext.xml",
"classpath:/spring/app-config.xml", ……
改成
@ContextConfiguration(locations = { "classpath*:/spring/applicationContext.xml",
"classpath*:/spring/app-config.xml",
就好了。
可能是因为项目里引用了其他项目,有相同名称的spring配置文件导致的。在classpath后加上*就可以了。
http://containsoft.iteye.com/blog/1766347