Everytime we take our application to a new environment, there are always settings that have to be adjusted. We don't want to edit code. Instead, it's easier if we could just override various properties. And we can!
This was touched on briefly in Chapter 1, Quick Start with Java, under the guise of overriding Spring Boot's property settings. However, the fact that we can write our own custom configuration property beans makes this a powerful feature for application customization.
To recap the rules listed in Chapter 1, Quick Start with Java, property settings can be overridden in the following order, highest to lowest:
- @TestPropertySource annotations on test classes.
- Command-line arguments.
- Properties found inside SPRING_APPLICATION_JSON (inline JSON embedded in an env variable or system property).
- ServletConfig init parameters...