spring boot的多环境配置

1、在原有的基础上增加application-xxx.yml文件

2、在application.yml中增加spring.profiles.active=xxx

就会使用application-xxx.yml覆盖原来文件的配置

 

小知识:springboot运行的时候指定的配置

a、mvn clean package

b、cd target

c、java  -jar springmvcdemo-0.0.1-SNAPSHOT.jar --spring.profiles.active=test --server.port=9090

resources下面一般有四个配置文件 application.yml 、application-dev.yml、application-prod.yml、application-test.yml你需要用哪个就可以配置哪个文件。

3、结果如图
spring boot的多环境配置

spring boot的多环境配置

spring boot的多环境配置