pom.xml中在<parent
>标签下配置属性,切换环境时,使用activation
<profiles>
<!-- 开发环境 -->
<profile>
<id>dev</id>
<properties>
<profiles.active>dev</profiles.active>
</properties>
<activation>
<!-- 默认环境 -->
<activeByDefault>true</activeByDefault>
</activation>
</profile>
<!-- 生产环境 -->
<profile>
<id>pro</id>
<properties>
<profiles.active>pro</profiles.active>
</properties>
<!-- <activation>-->
<!-- <activeByDefault>true</activeByDefault>-->
<!-- </activation>-->
</profile>
</profiles>
application.yml中配置
spring:
cron: false
profiles:
active: @profiles.active@
配置文件名称分别是
application-dev.yml
application-prod.yml