spring cloud 配置文件application.yml和bootstrap.yml 的定位,區別和聯繫總算是有一點明白了

最近在啓用springcloud配置中心server的東西,在整理屬性資源的時候,忽然發現:用了這麼久的springboot,爲何會配置兩個屬性文件同時存在(application.yml/properties,bootstrap.yml/properties).html

下面的解釋,我認爲是最通俗易懂的:spring

個人理解來說,其實就是說:1.加載順序的前後,bootstrap會先加載,在結合configserver一塊兒使用時,bootstrap屬性文件更適合作一些引導下文的配置,好比:bootstrap

# 默認配置
spring:
  application:
    name: demo
  cloud:
    config: #配置文件獲取
      uri: http://localhost:8040
      label: management
      name: application-demo

2.在結合configserver使用時,bootstrap更多的是配置一些不常常變化甚至不變化的屬性。application屬性文件可更靈活的配置一些屬性. (我的拙見,歡迎拍磚)springboot

官網文檔地址:https://cloud.spring.io/spring-cloud-static/Dalston.SR5/single/spring-cloud.html#_the_bootstrap_application_contextapp

相關文章
相關標籤/搜索