规范的maven项目路径为
myproject/
|-- pom.xml
`-- src
|-- main
| |-- java
| | `-- com
| | `-- mycompany
| |-- resources
| `-- webapp
| |-- WEB-INF
| | `-- web.xml
| `-- index.jsp
`-- test
|-- java
| `-- com
| `-- mycompany
`-- resources
如果我们的项目是非规范的maven项目,或者说我们想对maven项目的目录进行指定修改
可以用如下pom.xml
sourceDirectory目录涉及到 class中java的发布
warSourceDirectory涉及到 jsp的发布
如果没设置对,发布后的项目中就会有jsp或者.class文件缺失
<build>
<sourceDirectory>src/</sourceDirectory>
<resources>
<resource>
<directory>src</directory>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</resource>
<resource>
<directory>resource</directory>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.5</version>
<configuration>
<webXml>./WebRoot/WEB-INF/web.xml</webXml>
<warSourceDirectory>WebRoot</warSourceDirectory>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.17</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<version>2.5.5</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>2.13</version>
<configuration>
<configLocation>resource/checkstyle_checks.xml</configLocation>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
<version>3.2</version>
</plugin>
</plugins>
</build> |