springboot spring.config.activate.on-profile

spring.config.activate.on-profile

spring.config.activate.on-profile

spring.config.activate.on-profile

springboot 的 spring.config.activate.on-profile 可以用于 .yml .yaml 配置文件中

因为
一个 .yml .yaml 配置文件可以被 ---(三减号横杆) 分割为多个

例如:

spring.profiles.active: c

---
spring.config.activate.on-profile: a
name: aaa

---
spring.config.activate.on-profile: b
name: bbb

---
spring.config.activate.on-profile: c
name: ccc

---
spring.config.activate.on-profile: d
name: ddd

spring.profiles.active: c则 name=ccc

或者

spring.profiles.include: b

---
value: aaaaaa
spring:
  config:
    activate:
      on-profile: a

---
value: bbbbbb
spring:
  config:
    activate:
      on-profile: b

---
value: cccccc
spring:
  config:
    activate:
      on-profile: c

---
value: dddddd
spring:
  config:
    activate:
      on-profile: d

spring.profiles.active: b则 value=bbbbbbbb



spring.config.activate.on-profile 自 springboot2.4版开始使用,
它之前的名称是spring: profiles

Logo

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。

更多推荐