springboot配置文件的加载先后顺序

25 阅读1分钟

springboot配置文件的加载先后顺序

1、内部配置加载顺序:

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

  1. 命令行配置
  2. –file:./config/ --> jar包所在的目录的config目录下
  3. –file:./ --> jar包所在目录
  4. –classpath:/config/ --> jar包中的resources/config目录下
  5. –classpath:/ --> jar包中的resources目录下

nacos上的配置 > 命令行配置 > system env > classpath:application.yml > classpath:bootstrap.yml