idea创建maven工程后,在src/test/java下的class,使用spring注入时不能自动找到相应的配置文件。
@ContextConfiguration(locations = { "classpath:applicationContext.xml" })
就是这一行提示错误。
解决方法:
src/test/resources右击,选择mark dirctory as test resources root。
即可。
IDEA Maven项目Spring配置问题
本文介绍了解决IDEA中Maven项目src/test/java下使用Spring注入时找不到配置文件的问题。通过将src/test/resources目录标记为test resources root,即可正确加载classpath下的applicationContext.xml。
idea创建maven工程后,在src/test/java下的class,使用spring注入时不能自动找到相应的配置文件。
@ContextConfiguration(locations = { "classpath:applicationContext.xml" })
就是这一行提示错误。
解决方法:
src/test/resources右击,选择mark dirctory as test resources root。
即可。
471
2862
591

被折叠的 条评论
为什么被折叠?