4 Externalized Configuration Management

 

This chapter covers:

  • Configuring Spring with properties and profiles
  • Leveraging external configuration with Spring Boot
  • Implementing a configuration server with Spring Cloud Config Server
  • Configuring applications with Spring Cloud Config Client

In the previous chapter, you built a RESTful application for managing books in a public library, ran it in your local development environment, and finally pushed your changes to a remote repository. After that, you would probably package the application and deployed it to different environments, possibly in an automated way. For example, you would run it on a Continuous Integration (CI) server (as you did with GitHub Actions), on a Quality Assurance (QA) environment, on a staging environment, and finally in production. Depending on where it is deployed, the same application will have different needs and will most likely require a different configuration.

Note

Configuration is defined as everything likely to change between deployments, like credentials, resource handlers, and URLs to backing services.

4.1  Configuration in Spring: properties and profiles

4.1.1  Properties: Key/value pairs for configuration

4.1.2  Profiles: Configuration groups and when to use them in the cloud

4.2  Externalized configuration: one build, multiple configurations

4.2.1  Configuring an application through command-line arguments

4.2.2  Configuring an application through JVM system properties

4.2.3  Configuring an application through environment variables

4.3  Centralized configuration management with Spring Cloud Config Server

4.3.1  Using Git to store your configuration data

4.3.2  Setting up a configuration server

4.4  Using a configuration server with Spring Cloud Config Client

4.4.1  Setting up a configuration client

4.4.2  Refreshing configuration at runtime

4.5  Summary