多环境的配置

目录

多环境配置

对开发环境、生产环境、测试环境提供不同的配置信息。

使用 properties

  • 命名
    文件命名必须符合applicaiton-xx.properties
     applicaiton-dev.properties
     applicaiton-test.properties
  • 指定使用哪种配置环境
    在全局配置文件中(application.properties)指定使用哪种环境
       spring.profiles.active=dev  #使用dev环境
       spring.profiles.activetest=test使用dev环境

yml

在yml文件中使用三个短横线分割文档块
使用dev配置

spring:
  profiles:
    active: dev

---
spring:
  profiles: test
server:
  port: 8001

---
spring:
     profiles: dev
server:
  port: 8002

猜你喜欢

转载自www.cnblogs.com/lilihai/p/10160620.html