Overriding property settings in production

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:

  1. @TestPropertySource annotations on test classes.
  2. Command-line arguments.
  3. Properties ...

Get Learning Spring Boot 2.0 - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.