当我使用mvn clean package -DskipTests
时,控制台会显示:
WEB-INF\web.xml already added, skipping
如果web.xml没有引用pom中的任何参数,这没有坏处。但是如果你有一个从maven获取参数的路径,那么这将保留字符串原样。
那么这个web.xml复制竞争如何出来?以及如何解决? 控制台:
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building wx-common 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ wx-common ---
[INFO] Deleting D:\FROM WORKSPACE\workspace\wxflow\wx-common\target
[INFO]
[INFO] --- maven-resources-plugin:2.6:copy-resources (copy-resources) @ wx-common ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 8 resources
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ wx-common ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 14 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ wx-common ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 176 source files to D:\FROM WORKSPACE\workspace\wxflow\wx-common\target\classes
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ wx-common ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory D:\FROM WORKSPACE\workspace\wxflow\wx-common\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ wx-common ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 20 source files to D:\FROM WORKSPACE\workspace\wxflow\wx-common\target\test-classes
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ wx-common ---
[INFO] Tests are skipped.
[INFO]
[INFO] --- maven-war-plugin:2.2:war (default-war) @ wx-common ---
[INFO] Packaging webapp
[INFO] Assembling webapp [wx-common] in [D:\FROM WORKSPACE\workspace\wxflow\wx-common\target\wx-common-0.0.1-SNAPSHOT]
[INFO] Processing war project
[INFO] Copying webapp resources [D:\FROM WORKSPACE\workspace\wxflow\wx-common\src\main\webapp]
[INFO] Webapp assembled in [267 msecs]
[INFO] Building war: D:\FROM WORKSPACE\workspace\wxflow\wx-common\target\wx-common-0.0.1-SNAPSHOT.war
[INFO] WEB-INF\web.xml already added, skipping
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
pom profile and build:
<profiles>
<profile>
<id>dev</id>
<properties>
<deploy.type>dev</deploy.type>
<rp.build.warname>wx-common</rp.build.warname>
<property.path>/wx-common/prod</property.path>
</properties>
</profile>
</profiles>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.6</version>
<executions>
<execution>
<id>copy-resources</id>
<phase>validate</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${project.build.outputDirectory}</outputDirectory>
<resources>
<resource>
<directory>src/main/resources/${deploy.type}</directory>
<filtering>true</filtering>
<excludes>
<exclude>sms.properties</exclude>
</excludes>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
<excludes>
<exclude>**/dev/*</exclude>
</excludes>
<includes>
<include>**/mappers/*</include>
<include>*</include>
</includes>
</resource>
</resources>
</build>