springboot启动时拷贝jar包资源目录到项目资源目录
时间: 2023-11-20 08:06:42 浏览: 44
在Spring Boot项目中,可以通过在pom.xml文件中添加以下配置,将Jar包中的资源文件拷贝到项目资源目录中:
```xml
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
<excludes>
<exclude>**/*.jar</exclude>
</excludes>
</resource>
<resource>
<directory>${project.build.directory}/dependency</directory>
<filtering>false</filtering>
<includes>
<include>*.jar</include>
</includes>
</resource>
</resources>
</build>
```
上述配置将项目中的src/main/resources目录下的文件进行过滤,并排除了所有的.jar文件。然后将${project.build.directory}/dependency目录下的所有.jar文件包含到项目资源中。这样,项目启动时就可以访问这些jar包中的资源文件了。
相关推荐
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)