SpringBoot configuration properties load priority order and
- In your home directory (devtools when activated, compared with
~/.spring-boot-devtools.properties
) Devtools global settings attributes. - To use in the test
@TestPropertySource
comment. - To use in the test
properties
properties, it may be@SpringBootTest
for a testing application testing annotation portion. - Command line parameters.
- From
SPRING_APPLICATION_JSON
property (embedding property system environment variable or system propert [] Inline JSON). ServletConfig
Initialization parameters.ServletContext
Initialization parameters.- From
java:comp/env
JNDI property. - Java system properties
System.getProperties()
( ). - Operating system environment variables.
- Only
random.*
propertyRandomValuePropertySource
. - The application specified profile properties file (packaged in a jar of external
application-{profile}.properties
and YAML variable). - The application specified profile properties file (inside the jar packaged
application-{profile}.properties
and YAML variable). - In the jar outside the packaged application properties files (
application.properties
and YAML variable). - Inside the jar packaged applications properties files (
application.properties
and YAML variable). - In
@Configuration
the class@PropertySource
notes. - The default attribute (using
SpringApplication.setDefaultProperties
specified).
More add-ons in the smaller the number of loads about earlier, the higher the priority.
It is a common configuration properties 4,12,13,14,15,16
Reference: SpringBoot Chinese document https://docshome.gitbooks.io/springboot/content/