Springboot中l和l的加载顺序1. 若l 和l 在同⼀⽬录下,则l 的加载顺序要⾼于l,即l  会优先被加载。
原理:l ⽤于应⽤程序上下⽂的引导阶段。
•l 可以理解成系统级别的⼀些参数配置,这些参数⼀般是不会变动的。
•l 可以⽤来定义应⽤级别的,如果搭配 spring-cloud-config 使⽤ l ⾥⾯定义的⽂件可以实现动态替换。
使⽤Spring Cloud Config Server时,应在 l 中指定:
1        2spring.application.name fig.server.git.uri
2. 不同位置的配置⽂件的加载顺序:
在不指定要被加载⽂件时,默认的加载顺序:由⾥向外加载,所以最外层的最后被加载,会覆盖⾥层的属性(参考官⽹介绍)
SpringApplication will load properties from application.properties files in the following locations and add them to the
Spring Environment:
1. A /config subdirectory of the current directory.    //位于与jar包同级⽬录下的config⽂件夹,
2. The current directory                            //位于与jar包同级⽬录下
3. A classpath /config package          //idea 环境下,resource⽂件夹下的config⽂件夹
4. The classpath root                                //idea 环境下,resource⽂件夹下(1->4, 外->⾥)
bootstrap项目
The list is ordered by precedence (properties defined in locations higher in the list override those defined in lower locations).
3. 可以通过属性指定加载某⼀⽂件:
java -jar myproject.jar --fig.location=classpath:/default.properties,classpath:/override.properties
当通过fig.location 指定⼀个配置⽂件时,配置⽂件的搜索顺序如下:
1. file:./custom-config/
2. classpath:custom-config/
3. file:./config/
4. file:./
5. classpath:/config/
6. classpath:/
最下层的优先加载,所以最上层的属性会覆盖下层的属性;
4. 如果使⽤spring-cloud-config时,项⽬内部的resource下有l⽂件,并且在l ⾥配置
spring.application.name, git.url,spring.active.profies. 将项⽬打成jar包,放到服务器上,与jar包并列的位置,有start.sh脚本,
a. 在start 脚本⾥指定了配置⽂件:fig.location=./l, 则配置⽂件的加载顺序将为:
1. cloud-config 仓库⾥指定的yml 配置;
2. ./l
3. classpath:/l
4. 外部l
5. 内部l
b. 在start 脚本⾥指定了配置⽂件:fig.location=./l, 则配置⽂件的加载顺序将为:
1. cloud-config 仓库⾥指定的yml 配置;
2. ./l
3.  classpath:/l
4. ./l
5. classpath:/l
所以,不管是jar包内还是jar运⾏的同级⽬录下,只要包含l ,且为云配置,则云配置⽂件会覆盖其他配置⽂件;