SpringBoot 配置加载优先级顺序
                根据官网和极客时间丁雪丰老师 Spring 专课,总结归纳下 SpringBoot 加载配置的顺序,以便以后遇到问题了好排查。
外化配置优先级顺序:
- 开启 DevTools 时,~/.spring-boot-devtools.properties;
 - 测试类上的 @TestPropertySource 注解;
 - @SpringBootTest#properties 注解;
 - 命令行参数,如 –server.port=8888;
 - SPRING_APPLICATION_JSON 属性;
 - ServletConfig 初始化参数;
 - ServletContext 初始化参数;
 - Java:comp/env 中的JNDI 属性;
 - System.getProperties()属性;
 - 操作系统环境变量;
 - random.* RrandomValuePropertySource,如 my.age=${random.int}
 - jar 包外部的 application-(profile).properties 或(yml)
 - jar 包内部的 application-(profile).properties 或(yml)
 - jar 包外部的 application.properties 或(yml)
 - jar 包内部的 application.properties 或(yml)
 - @Configuration 类上的 @PropertySpurce;
 - SpringApplication.setDefaultProperties() 设置默认属性。
 
- Title: SpringBoot 配置加载优先级顺序
 - Author: 薛定谔的汪
 - Created at : 2019-04-15 17:48:32
 - Updated at : 2023-11-17 19:37:36
 - Link: https://www.zhengyk.cn/2019/04/15/springboot/spring-boot-config-load-order/
 - License: This work is licensed under CC BY-NC-SA 4.0.