SpringBoot之配置文件加载位置

108 阅读1分钟

1、配置文件扫描顺序

SpringBoot启动会扫描application.properties或者application.yml文件作为springboot的配置文件。默认创建项目生成application.properties/yml位置在classpath目录下,也可以在以下4个地方创建,优先级自上而下,但是各个配置文件成互补状态存在。

  1. file: ./config/   
  2. file: ./   
  3. classpath: /config/   
  4. classpath:/