SpringBoot配置文件加载顺序

spring boot启动会扫描以下位置的application.properties或者application.yml文件作为springboot的默认配置文件

-file:./config/

-file:./

-classpath:/config/

-classpath: /

以上是按照优先级从高到低的顺序,所有位置的文件都会被加载,高优先级配置内容会覆盖低优先级配置内容

SpringBoot配置文件加载顺序

可以用java -jar test.jar --spring.config.location=PWD   命令行优先级最高