SpringBoot多配置文件,切换环境

多配置文件

properties配置方式

SpringBoot多配置文件,切换环境

 application.properties

#通过active指定选用配置环境
spring.profiles.active=test

application-dev.properties

#开发环境
server.port=8081

application-test.properties

#测试环境
server.port=8082

application-pro.properties

#生产环境
server.port=8083

yml配置方式

SpringBoot多配置文件,切换环境

 application.yml

#通过active指定选用配置环境
spring:
  profiles:
  active: pro

application-dev.yml

#开发环境
server:
  port: 8081

application-test.yml

#测试环境
server:
  port: 8082

application-pro.yml

#生产环境
server:
  port: 8083