在实际部署过程中,我们有本地开发环境,测试环境,生产环境。
maven prefile 特性为我们提供了对,不同环境配置文件的管理,
通过对prefile的设置,在编译时 自动加载 相应环境的配置文件。
设置如下:
在 pom.xml 中加入如下配置:
<profiles>
<profile>
<id>dev</id>
<properties>
<profiles.active>dev</profiles.active><!--开发环境 -->
</properties>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
</profile>
<profile>
<id>test</id>
<properties>
<profiles.active>test</profiles.active><!--测试环境 -->
</properties>
</profile>
<profile>
<id>product</id>
<properties>
<profiles.active>product</profiles.active><!--生产环境 -->
</properties>
</profile>
</profiles>
<build>
<plugins>