这个问题 主要是maven的基础知识。
一、maven中pom打包。
pom的目录结构
|-- pom.xml
`-- src
|-- main
| |-- java
| | `-- com
| | `-- mycompany
| | `-- app
| | `-- App.java
| `-- resources
| `-- db.properties
--- spring.xml
`-- test
`-- java
`-- com
`-- mycompany
`-- app
`-- AppTest.java
打包之后 (大概的意思)
--WEB-INF
--classes
--com
--mycompany
--spring.xml
--db.properties
--lib
web.xml
<resources>
标签
<resources> 标签位于 <build> 标签内,用于指定项目资源文件的位置。例如,我们有一个 configuration.xml 文件,我们的项目要求这个文件位于 META-INF/plexus 中,虽然我们可以将其放置在 src/main/resource/META-INF/plexus 中,但我们给了这个文件自己的目录 src/main/plexus ,为了将其正确地打包进 jar 中,我们可以使用如下的配置
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
https://maven.apache.org/xsd/maven-4.0.0.xsd">
<build>
...
<resources>
<resource>
<targetPath>META-INF/plexus</targetPath>
<filtering>false</filtering>
<directory>${basedir}/src/main/plexus</directory>
<includes>
<include>configuration.xml</include>
</includes>
<excludes>
<exclude>**/*.properties</exclude>
</excludes>
</resource>
</resources>
<testResources>
...
</testResources>
...
</build>
</project>
- resources:资源文件列表
- targetPath:放置资源文件的目录,默认是根路径
- filtering:是否过滤资源文件
- directory:资源文件所在目录
- includes:需要包含的文件列表
- excludes:需要排除的文件列表
- testResources:测试资源文件列表,配置类似 resources