创建配置文件夹
profiles定义如下
<profiles>
<profile>
<id>dev</id>
<properties>
<package.environment>resources</package.environment>
</properties>
</profile>
<profile>
<id>test</id>
<properties>
<package.environment>test</package.environment>
</properties>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
</profile>
<profile>
<id>online</id>
<properties>
<package.environment>online</package.environment>
</properties>
</profile>
<profile>
<id>online-test</id>
<properties>
<package.environment>online-test</package.environment>
</properties>
</profile>
</profiles>
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.xml</include>
</includes>
</resource>
<resource>
<directory>src/main/${package.environment}</directory>
<includes>
<include>**/*.*</include>
</includes>
<filtering>true</filtering>
</resource>
</resources>
使用 -P来选择配置环境
clean package -Dmaven.test.skip=true -P online-test
<activation>
<activeByDefault>true</activeByDefault>
</activation>
选择默认选中的配置