SpringBoot java.io.FileNotFoundException: Could not open ServletContext resource [/config.properties]

阅读 230 标签:java基础  java框架  SpringBoot  

错误:

SpringBoot项目,单元测试的时候,报错:

 java.io.FileNotFoundException: Could not open ServletContext resource [/config.properties]


原因:

这个原因不是config.properties配置找不到,而是项目中存在@PropertySource注解

@PropertySource("config.properties")

解决办法:

@PropertySource("config.properties")

改成

@PropertySource("classpath:config.properties")

文章来源:网络 版权归原作者所有,如涉及知识产权问题,请权利人联系我们,我们将立即处理.
妈呀我要变身!
文章 51 获得 0个赞 共 0个粉丝

推荐阅读 更多精彩内容