Skip to content

Latest commit

 

History

History
 
 

code

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Configuration

This section of the lab looks at how to configure applications.

Spring Framework

We’ll start with a look at the Spring Framework, which provides the Environment abstraction and a concept of profiles and the @PropertySource annotation.

The Environment abstraction is a Spring application’s gateway to the environment around it. Inject it in any object and then use it to ask questions like "what profiles are active" and "what’s the value for this property?" A property, in this case, refers to a key and a value. Spring can read properties from any PropertySource in a chain of configured PropertySource instances.

Spring Boot

Then, it looks at how Spring Boot’s next-level support for configuration. Spring Boot normalizes external configuration (like -D arguments and environment variables) and even goes as far as canonicalizing external configuration properties such that, for example, the shell variable SERVER_PORT is the same as -Dserver.port, which is the same as putting server.port in a .properties file. Spring Boot also adds novel support for .yml configuration files. Spring Boot will, by convention, look for src/main/resources/application.properties and src/main/resources/application.yml, too.

Spring Cloud

Then, we look at how Spring Cloud supports cloud-native applications and operational requirements by supporting journaled, centralized configuration for multiple applications and services through the Spring Cloud config server. The Spring Cloud config server is backed by a Git. This promotes traceability and easier updates to configuration since there’s no need to re-push an application just to change its configuration. Additionally, Spring Cloud supports refreshing configuration for beans in-situ through the /refresh Actuator endpoint and through the Spring Cloud event bus (which uses RabbitMQ as a message bus to propagate configuration changes to all connected applications or services).