Search code examples
springspring-bootspring-boot-configuration

Shared Config Between SOME Spring Boot Services


This question is similar to (but different in the aim): Shared Config(at git) between SPring Boot Services so I will make use of the example the OP wrote there.

In my case I am using Spring Cloud Config Server with the Vault as backend, but for the sake of argument I will describe it as if it were in git. So imagine I have 4 Services: A, B, C and D.

And I have the following configs:

- A-prod.properties
- A-dev.properties
- B-prod.properties
- B-dev.properties
- C-prod.properties
- C-dev.properties
- D-prod.properties
- D-dev.properties
- application-prod.properties
- application-dev.properties

Now according to the docs I will have one of the services, let's say Service C getting his properties from C-(ENV).properties as well as application-(ENV).properties. Similarly the same with the others, i.e. everyone gets their own file and everything on application.properties.

My question is: Is it possible to have for example a "semi-global" shared properties, e.g. a file that A and C share some config and another that B and D share some config?

An usage example would be DB Connection Credentials, where two services make use of one set of credentials, and the others another one.

I have been trying to find infos about this and doing some tests, but nothing that got me anywhere...


Solution

  • Unfortunately, it's not possible to achieve what you want. The only way to share properties is by using the application.properties(yml) file which is merged to every other configuration file.