-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Open
Labels
Description
Describe the bug
Spring Cloud Config 4.3.0
Spring Boot 3.5.6
Scenario 1
application.yml
spring.application.name: demo1
spring.profiles.active: local
spring.config.import: "optional:configserver:"
Logs
2025-10-23T01:30:58.535-07:00 INFO 26151 --- [demo1] [ main] com.example.demo.Demo1ApplicationKt : The following 1 profile is active: "local"
2025-10-23T01:30:58.548-07:00 INFO 26151 --- [demo1] [ main] o.s.c.c.c.ConfigServerConfigDataLoader : Fetching config from server at : http://localhost:8888
2025-10-23T01:30:58.548-07:00 WARN 26151 --- [demo1] [ main] o.s.c.c.c.ConfigServerConfigDataLoader : Could not locate PropertySource ([ConfigServerConfigDataResource@2f7a7219 uris = array<String>['http://localhost:8888'], optional = true, profiles = 'default']): None of labels [] found
2025-10-23T01:30:58.548-07:00 INFO 26151 --- [demo1] [ main] o.s.c.c.c.ConfigServerConfigDataLoader : Fetching config from server at : http://localhost:8888
2025-10-23T01:30:58.548-07:00 WARN 26151 --- [demo1] [ main] o.s.c.c.c.ConfigServerConfigDataLoader : Could not locate PropertySource ([ConfigServerConfigDataResource@2c177f9e uris = array<String>['http://localhost:8888'], optional = true, profiles = 'local']): None of labels [] found
2025-10-23T01:30:58.548-07:00 INFO 26151 --- [demo1] [ main] o.s.c.c.c.ConfigServerConfigDataLoader : Fetching config from server at : http://localhost:8888
2025-10-23T01:30:58.548-07:00 WARN 26151 --- [demo1] [ main] o.s.c.c.c.ConfigServerConfigDataLoader : Could not locate PropertySource ([ConfigServerConfigDataResource@5db4c359 uris = array<String>['http://localhost:8888'], optional = true, profiles = 'default']): None of labels [] found
From logs, for some reason config is fetched three times (default, active-profile, default). First two are expected based on docs, but third time is not.
Scenario 2
application.yml
spring.application.name: demo1
spring.profiles.active: local
---
spring.config.activate.on-profile: local
spring.config.import: "optional:configserver:"
Logs
2025-10-23T01:39:24.398-07:00 INFO 30180 --- [demo1] [ main] o.s.c.c.c.ConfigServerConfigDataLoader : Fetching config from server at : http://localhost:8888
2025-10-23T01:39:24.398-07:00 WARN 30180 --- [demo1] [ main] o.s.c.c.c.ConfigServerConfigDataLoader : Could not locate PropertySource ([ConfigServerConfigDataResource@3e587920 uris = array<String>['http://localhost:8888'], optional = true, profiles = 'local']): None of labels [] found
2025-10-23T01:39:24.398-07:00 INFO 30180 --- [demo1] [ main] o.s.c.c.c.ConfigServerConfigDataLoader : Fetching config from server at : http://localhost:8888
2025-10-23T01:39:24.398-07:00 WARN 30180 --- [demo1] [ main] o.s.c.c.c.ConfigServerConfigDataLoader : Could not locate PropertySource ([ConfigServerConfigDataResource@2ef8a8c3 uris = array<String>['http://localhost:8888'], optional = true, profiles = 'default']): None of labels [] found
When the import is included in a profile-specific document, the fetches happen in reverse order (active-profile, default)
Scenario 3
application.yml
spring.application.name: demo1
spring.profiles.active: local
spring.config.import: "optional:configserver:http://localhost:8000"
---
spring.config.activate.on-profile: local
spring.config.import: "optional:configserver:"
Logs
2025-10-23T01:43:59.266-07:00 INFO 32350 --- [demo1] [ main] o.s.c.c.c.ConfigServerConfigDataLoader : Fetching config from server at : http://remote:8000
2025-10-23T01:43:59.266-07:00 INFO 32350 --- [demo1] [ main] o.s.c.c.c.ConfigServerConfigDataLoader : Exception on Url - http://remote:8000:org.springframework.web.client.ResourceAccessException: I/O error on GET request for "http://remote:8000/demo1/default": remote. Will be trying the next url if available
2025-10-23T01:43:59.266-07:00 WARN 32350 --- [demo1] [ main] o.s.c.c.c.ConfigServerConfigDataLoader : Could not locate PropertySource ([ConfigServerConfigDataResource@27cf3151 uris = array<String>['http://remote:8000'], optional = true, profiles = 'default']): I/O error on GET request for "http://remote:8000/demo1/default": remote
2025-10-23T01:43:59.266-07:00 INFO 32350 --- [demo1] [ main] o.s.c.c.c.ConfigServerConfigDataLoader : Fetching config from server at : http://localhost:8888
2025-10-23T01:43:59.266-07:00 WARN 32350 --- [demo1] [ main] o.s.c.c.c.ConfigServerConfigDataLoader : Could not locate PropertySource ([ConfigServerConfigDataResource@63fd4873 uris = array<String>['http://localhost:8888'], optional = true, profiles = 'local']): None of labels [] found
2025-10-23T01:43:59.266-07:00 INFO 32350 --- [demo1] [ main] o.s.c.c.c.ConfigServerConfigDataLoader : Fetching config from server at : http://localhost:8888
2025-10-23T01:43:59.266-07:00 WARN 32350 --- [demo1] [ main] o.s.c.c.c.ConfigServerConfigDataLoader : Could not locate PropertySource ([ConfigServerConfigDataResource@1e11bc55 uris = array<String>['http://localhost:8888'], optional = true, profiles = 'default']): None of labels [] found
2025-10-23T01:43:59.266-07:00 INFO 32350 --- [demo1] [ main] o.s.c.c.c.ConfigServerConfigDataLoader : Fetching config from server at : http://remote:8000
2025-10-23T01:43:59.266-07:00 INFO 32350 --- [demo1] [ main] o.s.c.c.c.ConfigServerConfigDataLoader : Exception on Url - http://remote:8000:org.springframework.web.client.ResourceAccessException: I/O error on GET request for "http://remote:8000/demo1/local": remote. Will be trying the next url if available
2025-10-23T01:43:59.266-07:00 WARN 32350 --- [demo1] [ main] o.s.c.c.c.ConfigServerConfigDataLoader : Could not locate PropertySource ([ConfigServerConfigDataResource@7544a1e4 uris = array<String>['http://remote:8000'], optional = true, profiles = 'local']): I/O error on GET request for "http://remote:8000/demo1/local": remote
2025-10-23T01:43:59.266-07:00 INFO 32350 --- [demo1] [ main] o.s.c.c.c.ConfigServerConfigDataLoader : Fetching config from server at : http://remote:8000
2025-10-23T01:43:59.266-07:00 INFO 32350 --- [demo1] [ main] o.s.c.c.c.ConfigServerConfigDataLoader : Exception on Url - http://remote:8000:org.springframework.web.client.ResourceAccessException: I/O error on GET request for "http://remote:8000/demo1/default": remote. Will be trying the next url if available
2025-10-23T01:43:59.266-07:00 WARN 32350 --- [demo1] [ main] o.s.c.c.c.ConfigServerConfigDataLoader : Could not locate PropertySource ([ConfigServerConfigDataResource@70e0accd uris = array<String>['http://remote:8000'], optional = true, profiles = 'default']): I/O error on GET request for "http://remote:8000/demo1/default": remote
Looks like the order is
- main-default
- profile-active
- profile-default
- main-active
- main-default
Sample
Create new Spring Boot Project via intelliJ
Additional Question
The real use case in my project is that my config server url should be profile-dependent. In this case, what is the recommended approach for implementing this?
Something that looks like it could work
spring.application.name: demo1
spring.profiles.active: local
---
spring.config.activate.on-profile: local
spring.config.import: "optional:configserver:http://localhost:8000"
---
spring.config.activate.on-profile: dev
spring.config.import: "optional:configserver:http://localhost:8100"
---
spring.config.activate.on-profile: !local & !dev
# all other environments
spring.config.import: "optional:configserver:https://somedomain"