SpringBoot Profile 多环境配置
多配置文件配置(properties):格式: applicatino-{profile}.properties
默认: applicatino.properties
开发: applicatino-dev.properties
生产: applicatino-prod.properties
激活配置:
spring.profiles.active=dev 复制代码
多文档块配置(yml)
server: port: 9090 spring: profiles: active; dev --- server: port: 9091 spring: profiles: dev --- server: port: 9092 spring: profiles: prod 复制代码
Idea激活指定环境配置:Idea->Run/Debug Configuration->Program arguments:
--spring.profiles.active=dev 复制代码
Idea虚拟机参数Idea->Run/Debug Configuration->VM options
--Dspring.profiles.active=dev 复制代码
命令行激活指定环境配置:
java -jar xxx.jar --spring.profiles.active=dev