I have a git repo and I created a config folder inside it. Now in my spring-cloud-config server application I am trying to point it to config folder.
The configuration is as below:
spring.cloud.config.server.git.uri: https://github.com/test/tes-service/
spring.cloud.config.server.git.username=test
spring.cloud.config.server.git.password=test
spring.cloud.config.server.git.search-paths=config
But this configuration does not seems to be working. Is this the correct way to do it?
Comment From: spencergibb
Looks right, though we document searchPaths
, but spring-boot should accommodate for that.
Comment From: dsyer
Works for me. Maybe you could link to a sample project with a real git repo so we can take a closer look.
Comment From: jonnybbb
Works for me with this sample https://github.com/jonnybbb/config-repo.git for app2 as well. Any reason why not supporting a deeper subdirectory structure like in app1 for picking up configuration files with an AntPathMatcher pattern?
Comment From: dsyer
I don't see a compelling reason to do deeper directory searches. It's complicated by the fact that you don't control the order of the search any more (e.g. which should take precedence, app1/application.properties
or app1/src/main/resources/application.properties
?).
Comment From: jonnybbb
Good Point! Agree.
Comment From: akkannabiran
As per our design, we are maintaining the configurations like below. config/application.yml config/aat/application.yml config/uat/application.yml
searchPaths: config,config/aat
Is it possible to load the configuration for aat environment from config/application.yml and config/aat/application.yml?
Comment From: gsugambit
i had this same issue when i changed spring cloud versions. the root cause seems to be the change from searchpaths to search-paths.
Comment From: kishoredubey
I don't see a compelling reason to do deeper directory searches. It's complicated by the fact that you don't control the order of the search any more (e.g. which should take precedence,
app1/application.properties
orapp1/src/main/resources/application.properties
?).
What If I want to maintain different directories, per client ? it would make sense to have different folders under one repo and use each for different clients.. Also, the way we specify searchPaths at config-server, how about the ability to specify it from client? This is what I am trying to do with no success so far :)
Comment From: dsyer
Most people switch to different repo per client when they run out of road with a single search path. I don’t think we would ever support clients setting a search path on the server (it reveals too much about the implementation), but open a new issue about the search path if you want patterns (like we already support in the repo URI).
Comment From: tjrekha
Can someone please help in finding why this kind of directory structure is not working for configs https://github.com/tjrekha/configs.git
I have the below in bootsrap.properties in config server. tried with application.properties as well
spring.cloud.config.server.git.searchPaths='{application}/{profile}' server.port=8888 spring.cloud.config.server.git.uri=https://github.com/tjrekha/configs.git
the configs located in the root is working. the configs under client1 isn't working. can someone let me know what am I missing
Below is the pom.xml for config server
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-config-server</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
http://localhost:8888/test/dev - working
Comment From: dsyer
Please use StackOverfow for usage questions. It reaches a bigger and more specific audience. When you do that you might want to explain “doesn’t work” a bit more clearly.
Comment From: scorobogaci
It can be solved as following :
Suppose you have in your config repo properties for multimple services organized in folders: properties organized in folders
Then, your config file for config server looks like this :
server:
port: 8888
spring:
cloud:
config:
server:
git:
uri:[git repo]
search-paths:
- billing-service
- shipping-service
This way you can organize all the properties in one central config repository and tell spring config server in which folders to look for properties
Comment From: gitmykeul
Hi,
I would like each microservice to read properties from 4 property files, meaning for a service called "myService" with profile "dev", I want to be able to read from the following Git folders:
- config/myService/application-dev.yml (specific config for this service and this profile)
- config/myService/application.yml (specific config for this service no matter which profile)
- config/application-dev.yml (specific config for dev profile no matter which service)
- config/application.yml (shared config no matter which service, no matter which profile)
I tried several patterns in search-paths but when I start myService, it reads everything except the last one: application.yml from the root folder (config/application.yml)
Here is my config: ```spring: application: name: config-server cloud: config: server: git: uri: ssh://git@xxx:7999/qi/athena.git clone-on-start: true search-paths: ',{application},config/{application}, config/, config/' #search-paths: '{application}' #search-paths: 'config/{application}'
It seems the **_Sharing Configuration With All Applications_** does not work as expected:
[https://cloud.spring.io/spring-cloud-config/multi/multi__spring_cloud_config_server.html#_sharing_configuration_with_all_applications](url)
For info I am using Finchley.SR2 version.
Thank you.
**Comment From: deepsharma951**
Hi,
If we have same properties under different folder
like
ms-one
|--- application.properties
|--- application-prod.properties
|--- application-dev.properties
ms-two
|--- application.properties
|--- application-prod.properties
|--- application-dev.properties
we have define search path in spring cloud config bootstrap file
spring.cloud.config.server.git.search-paths=ms-one,ms-two
Now we have to load profile in client application then how we can load the profile?
I have define
spring.application.name=application
spring.profiles.active=dev
but how to define which folder.
Advance in thanks :)
**Comment From: sarang85**
Hello @deepsharma951, @dsyer
It can be solved. The trick is to give search-path {application} without quotes as given below. It was a little tricky as spring documentation mentions it as '{application}' , probably spring developers just wanted to highlight it with quotes.
In spring cloud server add below mentioned search path-
spring.cloud.config.server.git.search-paths={application} instead of spring.cloud.config.server.git.search-paths='{application}'
This sets the search path(on server side) equal to the name of client application name .
now if your microservices/applications- they should have spring.application.name as below
spring.application.name=ms-one
and
spring.application.name=ms-two
they would be looking the properties file within their respective folders of ms-one and ms-two.
Also check my(Sarang) answer in stackoverflow below
https://stackoverflow.com/questions/60500158/how-to-point-spring-cloud-config-server-to-a-git-folder-inside-a-git-repo/61298954#61298954
**Comment From: vineethmaller**
Hi,
The properties file was getting read when I configured to access git using username and password.
But when I changed it to SSH access, the properties file is not detected.
**Config Server properties snippet**
Username and Password
spring: application: name: ConfigServer cloud: config: server: git: uri: https://github.com/vineethmaller/springboot-configrepo.git username: vineethmaller password: * clone-on-start: true search-paths: - 'ws_user'
SSH
spring: application: name: ConfigServer cloud: config: server: git: uri: git@github.com:vineethmaller/springboot-configrepo.git clone-on-start: true search-paths: - 'ws_user' passphrase: ***** private-key: | -----BEGIN RSA PRIVATE KEY----- Proc-Type: 4,ENCRYPTED ....... ....... -----END RSA PRIVATE KEY----- ```
Does anybody what changes to make when using SSH?
Comment From: zacisco
hello i have same configuration like in 2 this posts msg 1 msg 2
this will be work in feature?
description: i have server-config-service repo with configs folder in root and search-paths can't read from config folder,read from root git folder with other-services-config folders only
Comment From: maxiao1204
Hi I still want to specific a folder in git repo from client side, but always failed, my config server and client properties are as blow: config server:
clent config properties:
can someone help me? thanks in advance!
Comment From: maxiao1204
I don't see a compelling reason to do deeper directory searches. It's complicated by the fact that you don't control the order of the search any more (e.g. which should take precedence,
app1/application.properties
orapp1/src/main/resources/application.properties
?).What If I want to maintain different directories, per client ? it would make sense to have different folders under one repo and use each for different clients.. Also, the way we specify searchPaths at config-server, how about the ability to specify it from client? This is what I am trying to do with no success so far :)
Hi Did you get it down? could you share the code?