Spring Boot 参数配置,加载的优先级顺序
1. 命令行参数。
2. 来自 Java:comp/env 的 JNDI 属性。
3. Java 系统属性(System.getProperties()).
4. 操作系统环境变量。
5. RandomValuePropertySource 配置的 random.* 属性值。
6. jar 包外部的 application-{profile}.properties 或 application.yml (带 spring.profile)配置文件。
7. jar 包内部的 application-{profile}.properties 或 application.yml (带 spring.profile)配置文件。
8. jar 包外部的 application.properties 或 application.yml (不带 spring.profile)配置文件。
9. jar 包内部的 application.properties 或 application.yml (不带 spring.profile)配置文件。
10. @Configuration 注解类上的 @PropertySource.
11. 通过SpringApplication.setDefaultProperties 指定的默认属性。
== 其中yml 文件的配置与 properties 文件只是缩进和简写的差别,除此无其他差异。==
`
参考:《深入浅出 SpringBoot 2.x . 杨开振 著》–人民邮电出版社 2018