Five essential things you will need to end doing from Life

We all want to live long and thrive, but somehow life appears to be dealing us the wrong cards. But is it the cards that are incorrect, or are we struggling to use them to your advantage? There is a…

Smartphone

独家优惠奖金 100% 高达 1 BTC + 180 免费旋转




Spring Cloud Config Server with Multiples Repositories

As said before the properties will be fetch from a git repository so let’s configure that.

First of all you will need clone the repository running in your terminal git clone https://github.com/solivaf/sc-config-server-example.git . After cloning the project you will find a file named application.yml in y src/main/resources/. This file has the app configuration as server port and repository URL.

Navigate to repository URL you will find a repository with three configuration files: application.yml, application-prod.yml and config.properties.

Let’s see how it works. Run the command below:

And performing the command

Or

Or even using the pattern {application}/{profile} as you can see below

In this last request we got a long response. By default, spring will return the application-{profile}.yml file and the default file if these file exists.

But can we use more than one repository for config server instance? Let’s see.

If you run the config server you will realized that is a small and very simple application but imagine if we have 15 applications and they don’t share the same repository. Now with the we have until we need deploy 15 config server instances, one for each application.

The Spring Cloud Config Server provides a configuration with multiples repositories and they can be accessed by url like the first example. The config server will fetch each configuration by a pattern, so your label {application} in the path will be the key to find the correct repository. Let’s configure our application.yml in our config server.

Until now we have this application.yml:

Now we should add our additional repositories as you can see below:

Restart the config server and perform the requests below.

Now we can see the repository used to application fooapp, as we don’t have any pattern mapped to this application, the config server will use the default app, now if we specify the pattern app-foo which is mapped in our config-server property file we should get another repository as response.

Now, we have the correct repository which was mapped in our property file and all files which represents our app-foo application. The response order represents the hierarchy of the file being the most priority the first file in the list.

As simple as it can be, Spring Config Server helps a lot when we you manage a lot of configuration properties. It is easy to use and deploy and not only Java developers can use this service.

I hope this short story could help you in some way. See you in the next short story.

Add a comment

Related posts:

Behind the Mask

Autistic people often feel the need to hide their autistic traits and have developed skills which mimic normal behaviours. It’s our ‘game face’ and it may mean that people with ASD appear to be much…

Why is chatbot necessary in customer service

We all have experienced our fair share of dealing with a representative of a certain company. In most cases, it has definitely not been a smooth sailing. This cumbersome process tends to consume a…

Quotes For Self Confidence

Quotes For Self Confidence Life: Such a short word but takes entire existence to percieve it’s true meaning. This sequence of phrases light some deep perceptions, thoughts, feelings, concepts and…