Externalizing environmental config using environment variables
In the previous recipes, we have a number of times eluded to the fact that the 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 come across having to set JAVA_HOME
or PATH
a few times and these would be the examples of environment variables. It is also a very important feature in case one deploys their application using a PaaS Platform 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 hard-coded in the application codebase...