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>
Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐