外部配置优先级
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
注解 properties
attribute on your tests. Available on@SpringBootTest
and 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). ServletConfig
init parameters.ServletContext
init parameters.- JNDI attributes from
java:comp/env
. - java系统变量
System.getProperties()
- 操作系统环境变量
- A
RandomValuePropertySource
that has properties only inrandom.*
. - jar包外的
application-{profile}.properties
andapplication-{profile}.yml
。Profile-specific application properties - jar包内的
application-{profile}.properties
andapplication-{profile}.yml
。Profile-specific application properties - jar包外的
application.properties
andapplication.yml
。 - jar包内的
application.properties
andapplication.yml
。 - @Configuration类上的
@PropertySource
注解 - 默认属性(specified by setting
SpringApplication.setDefaultProperties
)
若有 spring cloud config,默认情况 以 远端配置为准。