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 a catalog of books. As part of the implementation, you defined some data to configure certain aspects of the application (in an application.yml
file), for example, the Tomcat thread pool or connection timeout. The next step might be to deploy the application to different environments: first on a test environment, then staging, and finally production. What if you needed a different Tomcat configuration for each of these environments? How would you achieve that?
Traditional applications were usually packaged as a bundle, including both the source code and a series of configuration files containing data for different environments and selected through a flag at runtime. The implication was that every time you needed to update configuration data for a specific environment, you had to make a new application build. A variant to this process was to create a different build for each environment, meaning that you had no guarantee whether what you run in a staging environment would have worked in the same way in production because they would be different artifacts.