pom.xml 配置
<profiles>
<profile>
<id>dev</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<profileActive>dev</profileActive>
</properties>
</profile>
<profile>
<id>prod</id>
<properties>
<profileActive>prod</profileActive>
</properties>
</profile>
</profiles>
application.yml
spring:
# dev环境
profiles:
active: "@profileActive@"
直接使用 mvn clean package - P prod
就可以直接打包prod环境