idea 找不到classpath 为resource下的xml


注入时不能自动找到在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>        

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM