Hi
I have setup a spring cloud config server (2.2.3.RELEASE) with the following configuration:
spring:
application:
name: config-server
profiles:
active: composite
cloud:
config:
server:
composite:
- type: git
uri: <uri1>
username: <uname>
password: <pass>
cloneOnStart: true
force-pull: true
basedir: <basedir1>
timeout: 2
refreshRate: 120
- type: git
uri: <uri2>
username: <uname>
password: <pass>
cloneOnStart: true
force-pull: true
basedir: <basedir2>
timeout: 2
refreshRate: 120
The first git repo contains configuration file with the name myproject-dev.yml and the second one contains configuration file with name application-dev.yml
When the config client with spring.config.name = myproject pulls data from config server (using dev profile), the application-dev.yml file from the second repo comes along.
Is this an expected behavior? Is there any way to prevent getting application-dev.yml files along? Or, a way to specify application name with the git configuration parameters such that myproject is able to access only the first git repo.
Comment From: ryanjbaxter
Yes that is the expected behavior.
When you name a file with application-*
it applies to all apps.
The solution would be to rename application-dev.yml
to something else if its not meant to be applied to all applications.
Comment From: mn-ar
Thank you for the response. Is it possible to create a custom environment repository and override this default behavior.
Comment From: ryanjbaxter
Yup you just need to provide your own Beans.
You can look at EnvironmentRepositoryConfiguration
to see what Beans you might need to create.
Comment From: mn-ar
Ok, thank you. Let me look into it. Any samples for reference please.
Comment From: ryanjbaxter
We dont have any samples that I recall, but its no different than providing bean to override behavior in any other Spring Boot application. If you run into problems or have questions let me know and I can help.