Spring boot 配置文件的加载顺序

Spring Boot 在启动时会扫描以下位置的 application.properties 或者 application.yml 文件作为全局配置文件:

bash 复制代码
--file:./config/

--file:./

--classpath:/config/

--classpath:/

以下是按照优先级从高到低的顺序,如下所示:

Spring Boot 会全部扫描上图中的这四个位置,扫描规则是高优先级配置内容会覆盖低优先级配置内容。而如果高优先级的配置文件中存在与低优先级配置文件不冲突的属性,则会形成一种互补配置,也就是说会整合所有不冲突的属性。

https://docs.spring.io/spring-boot/docs/2.1.13.RELEASE/reference/html/boot-features-external-config.html#boot-features-external-config-application-property-files

相关推荐
我叫张小白。2 小时前
Spring Boot拦截器详解:实现统一的JWT认证
java·spring boot·web·jwt·拦截器·interceptor
q***69774 小时前
Spring Boot与MyBatis
spring boot·后端·mybatis
r***12385 小时前
SpringBoot最佳实践之 - 使用AOP记录操作日志
java·spring boot·后端
LSL666_6 小时前
SpringBoot自动配置类
java·spring boot·后端·自动配置类
q***78376 小时前
Spring Boot 3.X:Unable to connect to Redis错误记录
spring boot·redis·后端
t***26597 小时前
SpringBoot + vue 管理系统
vue.js·spring boot·后端
qq_12498707538 小时前
基于springboot的疾病预防系统的设计与实现(源码+论文+部署+安装)
java·spring boot·后端·毕业设计
q***2519 小时前
Spring Boot 集成 Kettle
java·spring boot·后端
百***864610 小时前
Spring Boot应用关闭分析
java·spring boot·后端
程序员西西11 小时前
SpringBoot轻松整合Sentinel限流
java·spring boot·后端·计算机·程序员