maven 未将其它包下资源文件打包
时间: 2023-09-19 19:10:03 浏览: 135
默认情况下,Maven 构建会将 `src/main/resources` 目录下的资源文件打包到生成的 jar 包中。如果你需要将其他目录下的资源文件也打包到 jar 包中,需要在 pom.xml 文件中添加相应的配置。
例如,如果你想将 `src/main/webapp` 目录下的资源文件打包到 jar 包中,可以在 pom.xml 文件中添加以下配置:
```xml
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
</resource>
<resource>
<directory>src/main/webapp</directory>
</resource>
</resources>
</build>
```
以上配置会将 `src/main/resources` 和 `src/main/webapp` 目录下的资源文件一起打包到生成的 jar 包中。
如果你需要排除某些资源文件,可以在 `resource` 标签中添加 `excludes` 子标签,例如:
```xml
<resource>
<directory>src/main/webapp</directory>
<excludes>
<exclude>**/*.log</exclude>
</excludes>
</resource>
```
以上配置会将 `src/main/webapp` 目录下所有后缀为 `.log` 的文件排除在打包范围之外。
阅读全文
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20241231044930.png)
![rar](https://img-home.csdnimg.cn/images/20241231044955.png)
![rar](https://img-home.csdnimg.cn/images/20241231044955.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![rar](https://img-home.csdnimg.cn/images/20241231044955.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![rar](https://img-home.csdnimg.cn/images/20241231044955.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![-](https://img-home.csdnimg.cn/images/20241231045053.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![rar](https://img-home.csdnimg.cn/images/20241231044955.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)