一、idea配置文件
application.yml
spring:
profiles:
active: dev
application-dev.yml
server:
port: 8081
application-test.yml
server:
port: 8082
application-uat.yml
server:
port: 8083
application-prod.yml
server:
port: 8084
启动:
active: dev
二、pom文件配置
<profiles> <!-- 开发环境--> <profile> <id>dev</id> <properties> <spring.profiles.active>dev</spring.profiles.active> </properties> <activation> <activeByDefault>true</activeByDefault> </activation> </profile> <!-- 测试环境--> <profile> <id>test</id> <properties> <spring.profiles.active>test</spring.profiles.active> </properties> </profile> <!-- 预发布环境--> <profile> <id>uat</id> <properties> <spring.profiles.active>uat</spring.profiles.active> </properties> </profile> <!-- 线上环境--> <profile> <id>prod</id> <properties> <spring.profiles.active>prod</spring.profiles.active> </properties> </profile> </profiles>