Spring Boot 打包后,target目录下resources目录的文件消失——修改pom.xml
Spring Boot 打包解决target目录下没有resource目录相关文件
·
1.问题描述
在打包Spring Boot文件时候,发现target目录下没有生成src/main/resources目录下的文件。文件目录如下所示。
2.问题解决
需要在pom.xml文件下增加对resource目前的映射。主要如下所示:这里代表的是我文件夹下有.py 和.pth 和 .json格式的文件,所以这里需要一一对应。
pom.xml对资源映射的代码如下所示:(还加了一些图片后缀等等,后续可能会用到,就提前加上了。)
<resources>
<!-- 这里是为了解决打包之后,target/classes目录下也有对应的文件,比如Files; pythonFile ,必须一一对应-->
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.*</include>
</includes>
<filtering>true</filtering>
</resource>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>**/*.properties</include>
<include>**/*.yml</include>
<include>**/*.xml</include>
<include>**/*.tld</include>
<include>**/*.doc</include>
<include>**/*.png</include>
<include>**/*.jpg</include>
</includes>
<filtering>true</filtering>
</resource>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>**/*.png</include>
<include>**/*.jpg</include>
<include>**/*.xlsx</include>
<include>**/*.xls</include>
<include>**/*.txt</include>
<include>**/*.py</include>
<include>**/*.pth</include>
<include>**/*.json</include>
<include>Files/*</include>
<include>mapper/*</include>
<include>pythonFile/*</include>
</includes>
<excludes>
<exclude>**/*.properties</exclude>
<exclude>**/*.yml</exclude>
<exclude>**/*.xml</exclude>
<exclude>**/*.tld</exclude>
<exclude>**/*.doc</exclude>
</excludes>
<filtering>false</filtering>
</resource>
</resources>
更多推荐
已为社区贡献1条内容
所有评论(0)