最近在启用springcloud配置中心server的东西,在整理属性资源的时候,突然发现:用了这么久的springboot,为什么会配置两个属性文件同时存在(application.yml/properties,bootstrap.yml/properties).
下面的解释,我认为是最通俗易懂的:
我的理解来讲,其实就是说:1.加载顺序的先后,bootstrap会先加载,在结合configserver一起使用时,bootstrap属性文件更适合做一些引导下文的配置,比如:
# 默认配置
spring:
application:
name: demo
cloud:
config: #配置文件获取
uri: http://localhost:8040
label: management
name: application-demo
2.在结合configserver使用时,bootstrap更多的是配置一些不经常变化甚至不变化的属性。application属性文件可更灵活的配置一些属性. ( By default, bootstrap properties (not bootstrap.properties
but properties that are loaded during the bootstrap phase) are added with high precedence, so they cannot be overridden by local configuration.)