注入时不能自动找到在src/main/resources下的xml

@ContextConfiguration(locations = { “classpath:applicationContext.xml” })

这一行提示错误。

解决方法一:

resources右击,选择mark dirctory as test resources root

即可。

解决方法二:

pom.xml中可能被exclude,删掉就好

    <resource>

                <directory>src/main/resources/</directory>

                <excludes>

                    <exclude>local/*</exclude>

                    <exclude>dev/*</exclude>

                    <exclude>online/*</exclude>

                </excludes>

            </resource>

版权声明:本文为fswhq原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://www.cnblogs.com/fswhq/p/idea_classpath.html