外部配置优先级
https://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-external-config.html
- 当启用devtools时,当前用户目录下的
~/.spring-boot-devtools.properties配置。Devtools global settings properties - 测试时的
@TestPropertySource注解 propertiesattribute on your tests. Available on@SpringBootTestand the test annotations for testing a particular slice of your application.- 命令行参数
- Properties from
SPRING_APPLICATION_JSON(inline JSON embedded in an environment variable or system property). ServletConfiginit parameters.ServletContextinit parameters.- JNDI attributes from
java:comp/env. - java系统变量
System.getProperties() - 操作系统环境变量
- A
RandomValuePropertySourcethat has properties only inrandom.*. - jar包外的
application-{profile}.propertiesandapplication-{profile}.yml。Profile-specific application properties - jar包内的
application-{profile}.propertiesandapplication-{profile}.yml。Profile-specific application properties - jar包外的
application.propertiesandapplication.yml。 - jar包内的
application.propertiesandapplication.yml。 - @Configuration类上的
@PropertySource注解 - 默认属性(specified by setting
SpringApplication.setDefaultProperties)
若有 spring cloud config,默认情况 以 远端配置为准。