Issue
I'm trying to have a folder structure for my config repo.
root
├── serviceA
│ ├── application-dev.properties
│ └── application-prod.properties
├── serviceB
│ ├── application-dev.properties
│ └── application-prod.properties
In my config server I have the following in my application.yml
server:
port: 8081
spring:
application:
name: cloud-config-server
cloud:
config:
server:
monitor:
github:
enabled: true
gitee:
enabled: true
git:
password: ${PASSWORD}
username: ${USERNAME}
uri: ${LINK_TO_CONFIG}
default-label: master
search-paths: serviceA, serviceB
When running the server and requesting http://localhost:8081/serviceA/prod
or http://localhost:8081/serviceB/prod
I get the same result
{
"name":"serviceA",
"profiles":[
"prod"
],
"label":null,
"version":"9df32c9dbd11be65e892caf878ddc8d16906a849",
"state":null,
"propertySources":[
{
"name":"GITHUB_URI/springcloudconfigrepo/serviceB/application-prod.properties",
"source":{
"profile":"some-service-prod"
}
},
{
"name":"GITHUB_URI//springcloudconfigrepo/serviceA/application-prod.properties",
"source":{
"profile":"another-service-prod"
}
}
]
}
My question is, how can I fetch properties of serviceA only (or serviceB)?
My spring cloud config server on github is here
Solution
You need to set the configuration for searchPaths
as you application name.
The configuration should looks like this:
spring:
cloud:
config:
server:
git:
uri: ${LINK_TO_CONFIG}
searchPaths: '{application}'
Answered By - Sergio Santiago
Answer Checked By - Pedro (JavaFixing Volunteer)