0
点赞
收藏
分享

微信扫一扫

springboot多环境(dev、test、pro)配置

沐之轻语 2022-04-01 阅读 45

propertiest配置格式:
在Spring Boot中多环境配置文件名需要满足application-{profile}.properties的格式,其中{profile}对应你的环境标识,比如:
     application-dev.properties:开发环境
     application-test.properties:测试环境
     application-pro.properties:生产环境
至于哪个具体的配置文件会被加载,需要在application.properties文件中通过spring.profiles.active属性来设置,其值对应{profile}值。 

application.yml
spring:
  profiles:
    active: dev

application-dev.yml

# application-dev.yml
variable:
   profiles : dev
application-pro.yml

# application-pro.yml
variable:
   profiles : pro
 application-test.yml

# application-test.yml
variable:
   profiles : test

如:spring.profiles.active=dev就会加载application-dev.properties配置文件内容 

举报

相关推荐

0 条评论