Spring Boot 按照以下顺序加载配置(后面的会覆盖前面的):

📊 配置加载的优先级顺序(完整列表)

Spring Boot 按照以下顺序加载配置(后面的会覆盖前面的):

优先级从低到高(数字越大优先级越高):

  1. 默认属性(SpringApplication.setDefaultProperties)
  2. @Configuration 类上的 @PropertySource
  3. 配置文件(application.properties/yml)
    3.1. jar 包内的 application.properties
    3.2. jar 包内的 application-{profile}.properties
    3.3. jar 包外的 application.properties
    3.4. jar 包外的 application-{profile}.properties
  4. RandomValuePropertySource(random.* 属性)
  5. 操作系统环境变量
  6. Java 系统属性(System.getProperties())
  7. JNDI 属性(java:comp/env)
  8. ServletContext 初始化参数
  9. ServletConfig 初始化参数
  10. SPRING_APPLICATION_JSON 中的属性
  11. 命令行参数
  12. @TestPropertySource 注解(测试时)
相关推荐
Flynt12 分钟前
Spring AI Alibaba 真停更了?我把它的 GitHub 翻了个底朝天
java·spring·开源
ServBay2 小时前
AI 做的小工具,怎样交给同事用?
后端·aigc·ai编程
用户69371750013842 小时前
AI 越强,为什么我们反而越来越担心失业?
前端·后端·github
夜郎king2 小时前
Shapefile 一键生成 GeoServer 样式:GeoTools + Spring Boot 实现 YSLD 自动生成器
spring boot·gis·geotools·ysld
她的男孩3 小时前
Spring Boot 接 Flowable:请假单要同时走财务和行政,包容分支和默认分支怎么配
java·spring boot·工作流引擎
咖啡八杯4 小时前
LoginUser 适配器模式:适配 SysUser 到 UserDetails
java·开发语言·后端·框架·适配器模式·若依
拖孩5 小时前
又又又用 AI 写了个小程序:我站起来猛蹬 AI,使劲薅羊毛
前端·后端·微信小程序
北冥有鱼5 小时前
从 bean::method 里抠出注解:Java 方法引用元数据反查全记录
java·后端
CoderYanger6 小时前
Java EE 进阶:11. SpringBoot 统一功能处理(第四弹):@ControllerAdvice 源码分析+案例代码
java·数据库·spring boot·后端·spring·java-ee·mybatis
Sailing6 小时前
🔥🔥sql: waiting for connection 踩坑:不要一味调大 MaxOpenConns
后端·go·gin