<!--
pom文件新增==============================================
-->
<profiles>
<profile>
<!-- 开发环境 -->
<id>dev</id><!-- 编译时输入该变量-->
<properties>
<environment>DEV</environment><!-- 读取配置文件时,加上对应值`DEV`(大小写皆可)-->
</properties>
<activation>
<activeByDefault>true</activeByDefault><!-- 默认该环境配置文件-->
</activation>
</profile>
<profile>
<!-- 测试环境 -->
<id>dat</id>
<properties>
<environment>DAT</environment>
</properties>
</profile>
<profile>
<!-- 生产环境 -->
<id>prd</id>
<properties>
<environment>PRD</environment>
</properties>
</profile>
</profiles>
<build>
<resources>
<resource>
<directory>src/main/resources/config-${environment}</directory><!-- 配置文件从哪里读取,`environment`为上方值如:`DEV`,大小写皆可识别 -->
<!-- <filtering>true</filtering> -->
<targetPath>config</targetPath><!-- 配置文件放在哪里 -->
</resource>
</resources>
</build>
<!--
pom文件新增==============================================
-->
图解: