在plugins下添加以下代码
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.4</version>
<configuration>
<warName>${project.artifactId}</warName>
<warSourceExcludes>nodejs/**</warSourceExcludes>
<webResources>
<resource>
<filtering>true</filtering>
<directory>src/main/profile</directory>
<targetPath>WEB-INF</targetPath>
<includes>
<include>**/web.xml</include>
</includes>
</resource>
<resource>
<filtering>true</filtering>
<directory>src/main/profile/pages</directory>
<targetPath>pages</targetPath>
<includes>
<include>**</include>
</includes>
</resource>
</webResources>
<warSourceDirectory>src/main/webapp</warSourceDirectory>
<webXml>src/main/webapp/WEB-INF/web.xml</webXml>
</configuration>
</plugin>
src/main/profile的目录结构与打包后war的目录结构一致
targetPath即要替换的目录,include为要替换的文件
上面的代码会将src/main/profile替换WEB-INF下的web.xml,已经pages下的文件