Spring config
Context
When you understand something without context, the understanding is like a whiff of smoke. It goes off in fumes.
Spring config attains relevance in the context of multiple micro services in your application. Spring boot applications already have application context yaml where you can specify properties.
Let us look at a monolith that got split into multiple micro services. These individual micro services are clearly related. Thinking of the project I am working on at work right now, some configs tend to be dependent on each other across micro services.
For instance, I have a micro service that can call multiple external vendors, and in one of the micro services, I can customize all that I want in regards to how the particular vendor is being interacted with. However, it is in another micro service that the particular vendor is being enabled.
So, it makes sense to have centralized externalized config across these micro services. That is where spring config comes in.
Get Learn’s stories in your inbox
Join Medium for free to get updates from this writer.
How it works
This is in regards to how the configuration needs to be from the context of a single micro service.
Config saved in gitrepo
The configuration gets saved in a git repository.
Reference to the gitrepo
The microservice clearly would need to reference the config repo. This is in application context yaml file
spring:
config:
import: optional:configserver:https://myapplication-configservice/configDynamic Refresh
One additional benefit of the spring config service is that the config can be changed and dynamically refreshed without needing to restart the application.
Typically, if there is a need to make a config change over the application, they you need to change the property values in the application context yaml or properties file and restart the application.
Instead, with spring config approach, the property can be refreshed using a refresh property API invocation.






