Skip to main content

Posts

Showing posts from July, 2022

How to externalize your Spring configuration files for different environments in a distributed system

Introduction In this post we are going to see how we can create a Spring Configuration Server to externalize our Spring Boot application configuration files. In order to do that we need one Spring Boot application running as a configuration server, one Spring Boot application running as a configuration client and one external repo like GitHub to keep our configuration yml files. Config Server Let´s start by going to the Spring Initializr web site to create a Spring Boot project. For this project we just need one dependency, the Config Server from Spring Cloud Config as shown in the image below: This is all you need. You can go ahead and click in generate to download your Spring Boot project. Next, open your application.yml file and add the code below. We just need to add this configuration to let Spring know where to get our yml configuration files. Under repos we can add configurations for all the environments we need. I am just adding a section for my developme