maven打包 springBoot 工程时,默认识别resources目录,习惯使用 resource 目录的需要手动指定静态资源目录

最近项目开发,发现springBoot项目在使用maven打包时,我们静态资源文件都放在resource目录下面,大致如下:

在使用maven打包时,发现静态资源没有打进去。原来springBoot默认静态资源路径的时resources.

那解决静态资源文件使用maven打包问题的解决方案就有两种了:

    1.将静态资源文件夹名从resource改为resources

    2.在工程pom.xml中加入resource目录配置,手动去指定。我们习惯使用resource目录,所以使用了手动指定

<build>
<finalName>shengshi-property-management</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/resource</directory>
<includes>
<include>**/*</include>
</includes>
</resource>
</resources>
</build>

原文地址:https://www.cnblogs.com/ANCAN-RAY/p/7723142.html