Externalizing an environmental configuration using environment variables
In the previous recipes, we have, a number of times, alluded to the fact that configuration values to a Spring Boot application can be passed and overridden by using OS environment variables. Operating systems rely on these variables to store information about various things. We probably have to set JAVA_HOME
or PATH
a few times, and these are examples of environment variables. OS environment variables is also a very important feature if one deploys their application using a PaaS system such as Heroku or Amazon AWS. In these environments, configuration values such as database access credentials and various API tokens are all provided over the environment variables.
Their power comes from the ability to completely externalize the configuration of simple key-value data pairs without the need to rely on placing a property or some other files in a particular location, and having this hardcoded in the application code base...