直接上图,一目了然
配置文件
![配置文件](https://img-blog.csdn.net/20160105114207451)
web.xml文件配置
![web.xml配置](https://img-blog.csdn.net/20160105114524270)
pom.xml文件配置
<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 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>aaa</groupId>
<artifactId>aaa</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<name>aaa Maven Webapp</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<profiles>
<profile>
<id>dev</id>
<properties>
<env>dev</env>
</properties>
<build>
<filters>
<filter>src/main/env/dev/dubbo.properties</filter>
<filter>src/main/env/dev/mysql.properties</filter>
<filter>src/main/env/dev/sms.properties</filter>
</filters>
</build>
</profile>
<profile>
<id>test</id>
<properties>
<env>test</env>
</properties>
<build>
<filters>
<filter>src/main/env/test/dubbo.properties</filter>
<filter>src/main/env/test/mysql.properties</filter>
<filter>src/main/env/test/sms.properties</filter>
</filters>
</build>
</profile>
<profile>
<id>product</id>
<properties>
<env>product</env>
</properties>
<build>
<filters>
<filter>src/main/env/product/dubbo.properties</filter>
<filter>src/main/env/product/mysql.properties</filter>
<filter>src/main/env/product/sms.properties</filter>
</filters>
</build>
</profile>
</profiles>
<build>
<finalName>aaa</finalName>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<webResources>
<resource>
<filtering>true</filtering>
<directory>src/main/webapp</directory>
<includes>
<include>**/web.xml</include>
</includes>
</resource>
</webResources>
</configuration>
</plugin>
</plugins>
</build>
</project>
执行效果(以开发环境示例)
![执行效果](https://img-blog.csdn.net/20160105115336576)