不同环境配置形式:application-{profile}.properties
- application-dev.properties:开发环境
- application-test.properties:测试环境
- application-prod.properties:生产环境
通过在application.properties中设置spring.profiles.active=dev
来指定活动的profile
1.生产环境配置文件application-prod.properties
server.port=8090
或者是yml配置文件application-prod.yml
server:
port:8090
2.开发环境配置文件application-dev.properties
server.port=8080
或者是yml配置文件application-dev.yml
server:
port:8080
3.运行环境配置application.properties
#激活测试环境
spring.profiles.active=dev
#激活生产环境
spring.profiles.active=prod
yml运行环境配置application.yml
spring :
profiles :
# 环境 dev|test|prod
active : dev