Caused by: java.io.FileNotFoundException: class path resource [java110.properties] cannot be opened
1 异常maven工程Caused by: java.io.FileNotFoundException: class path resource [java110.properties] cannot be opened because it does not exist2 原因分析maven工程在启动运行时,是按照pom.xml进行打包到target中,此时我们可以打开target查看结构:不难
·
1 异常
maven工程
Caused by: java.io.FileNotFoundException: class path resource [java110.properties] cannot be opened because it does not exist
2 原因分析
maven工程在启动运行时,是按照pom.xml进行打包到target中,此时我们可以打开target查看结构:
不难看出,即使最重要的application.yml都没有打包进来,项目自然会启动报错,告诉你某某配置文件不存在。
2 解决方法
打开pom.xml,在resources中加入配置文件的路径。
例:
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.xml</include>
</includes>
</resource>
<!--设置自己目录下的配置文件-->
<resource>
<!--下方resources的文件夹名字要和自己项目的文件夹名确认一致才行 很多人就是忽略了名字不一致 -->
<directory>src/main/resources</directory>
<includes>
<include>**/*</include>
</includes>
</resource>
rebuild一下(如果rebuild没有效果就删掉target重新build):
可以看到该有的配置都有了。
有其他交流的想法,可以加我创建的Q群:820080257
更多推荐
已为社区贡献1条内容
所有评论(0)