一、properties
1. 开发环境
# 开发环境配置文件
server.port=8081
指定开发环境
# 指定要激活的profile多环境配置文件
spring.profiles.active=dev
测试结果
2. 生产环境
# 生产环境配置文件
server.port=8082
指定生产环境
# 指定要激活的profile多环境配置文件
spring.profiles.active=prod
测试结果
3. 测试环境
# 测试环境配置文件
server.port=8083
指定生产环境
# 指定要激活的profile多环境配置文件
spring.profiles.active=test
测试结果
二、yaml
以【---】分割配一个配置
server:
port: 8080
spring:
profiles:
active: dev
---
server:
port: 8081
spring:
profiles: dev
---
server:
port: 8082
spring:
profiles: test
---
server:
port: 8083
spring:
profiles: prod