A note from book Spring boot in Action, 1st edition by Craig Walls , chapter 3:
There are, in fact, several ways to set properties for a Spring Boot application. Spring Boot will draw properties from several property sources, including the following:
- Command-line arguments
- JNDI attributes from java:comp/env
- JVM system properties
- Operatiing system environment variables
- Randomly generated values for properties prefixed with random.* (referenced when setting other properties, such as ${random.long})
- An application.properties or application.yml file outside of the application
- An application.properties or application.yml file packaged inside of the application
- Property sources specified by @PropertySource
- Default properties
This list is in order of precedence. That is, any properties set from a source higher in the list will override the same property set on a source lower in the list.
This can be verified in Spring boot source code. I will try to dig and document it when I go to that.