最近在启用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