Ordering property overrides
Back in Chapter 1, Core Features of Spring Boot, we got a summary of the order of property settings.
Let’s see that list of options again:
- Default properties are provided by Spring Boot’s
SpringApplication.setDefaultProperties()
method. @PropertySource
-annotated@
Configuration
classes.- Config data (such as
application.properties
files). - A
RandomValuePropertySource
that has properties only in random.*. - OS environment variables.
- Java System properties (
System.getProperties()
). - JNDI attributes from
java:comp/env
. ServletContext
init parameters.ServletConfig
init parameters.- Properties from
SPRING_APPLICATION_JSON
(inline JSON embedded in an environment variable or system property). - Command-line arguments, as shown in the previous section.
properties
attribute on your tests. Available with the@SpringBootTest
annotation and also slice-based testing (which we covered back in Chapter 5, Testing...