Spring Cloud Config does not respect application.yml as default configuration
See original GitHub issueDescribe the bug I want to do one simple thing. It was possible earlier. On the cloud (kubernetes), I want to read config from the consul and merge it with application.yml On my laptop, I want to read the config only from application.yml
Sample Here is my configuration for the kubernetes
config:
import: "consul:"
cloud:
consul:
config:
enabled: true
watch:
enabled: false
format: yaml
fail-fast: true
prefixes: epsr
host: http://consul.dev.epsr
port: 80
Here is my configuration for my laptop
config:
import: ""
cloud:
consul:
config:
enabled: false
watch:
enabled: false
format: yaml
fail-fast: true
prefixes: epsr
host: http://consul.dev.epsr
port: 80
Why should I specify empty string for import? It is totaly undocumented.
I want to simply set spring.cloud.consul.config.enable=false
to complete disable the consul and read properties from the application.yml
If I do this and set spring.config.import: "consul:"
, I will get a error
java.lang.IllegalStateException: Unable to load config data from 'consul:'
at org.springframework.boot.context.config.StandardConfigDataLocationResolver.getReferences(StandardConfigDataLocationResolver.java:141)
at org.springframework.boot.context.config.StandardConfigDataLocationResolver.getReferences(StandardConfigDataLocationResolver.java:126)
at org.springframework.boot.context.config.StandardConfigDataLocationResolver.resolve(StandardConfigDataLocationResolver.java:119)
at org.springframework.boot.context.config.ConfigDataLocationResolvers.lambda$resolve$1(ConfigDataLocationResolvers.java:115)
at org.springframework.boot.context.config.ConfigDataLocationResolvers.resolve(ConfigDataLocationResolvers.java:126)
at org.springframework.boot.context.config.ConfigDataLocationResolvers.resolve(ConfigDataLocationResolvers.java:115)
at org.springframework.boot.context.config.ConfigDataLocationResolvers.resolve(ConfigDataLocationResolvers.java:107)
at org.springframework.boot.context.config.ConfigDataImporter.resolve(ConfigDataImporter.java:105)
at org.springframework.boot.context.config.ConfigDataImporter.resolve(ConfigDataImporter.java:97)
at org.springframework.boot.context.config.ConfigDataImporter.resolveAndLoad(ConfigDataImporter.java:85)
at org.springframework.boot.context.config.ConfigDataEnvironmentContributors.withProcessedImports(ConfigDataEnvironmentContributors.java:121)
at org.springframework.boot.context.config.ConfigDataEnvironment.processInitial(ConfigDataEnvironment.java:240)
at org.springframework.boot.context.config.ConfigDataEnvironment.processAndApply(ConfigDataEnvironment.java:227)
at org.springframework.boot.context.config.ConfigDataEnvironmentPostProcessor.postProcessEnvironment(ConfigDataEnvironmentPostProcessor.java:102)
at org.springframework.boot.context.config.ConfigDataEnvironmentPostProcessor.postProcessEnvironment(ConfigDataEnvironmentPostProcessor.java:94)
at org.springframework.boot.env.EnvironmentPostProcessorApplicationListener.onApplicationEnvironmentPreparedEvent(EnvironmentPostProcessorApplicationListener.java:102)
at org.springframework.boot.env.EnvironmentPostProcessorApplicationListener.onApplicationEvent(EnvironmentPostProcessorApplicationListener.java:87)
at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:176)
at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:169)
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:143)
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:131)
at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:85)
at org.springframework.boot.SpringApplicationRunListeners.lambda$environmentPrepared$2(SpringApplicationRunListeners.java:66)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1541)
at org.springframework.boot.SpringApplicationRunListeners.doWithListeners(SpringApplicationRunListeners.java:120)
at org.springframework.boot.SpringApplicationRunListeners.doWithListeners(SpringApplicationRunListeners.java:114)
at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:65)
at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:338)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:296)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1301)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1290)
at ru.stdev.smev3.SmevAdapterApplication$Companion.main(SmevAdapterApplication.kt:20)
at ru.stdev.smev3.SmevAdapterApplication.main(SmevAdapterApplication.kt)
Caused by: java.lang.IllegalStateException: File extension is not known to any PropertySourceLoader. If the location is meant to reference a directory, it must end in '/' or File.separator
at org.springframework.boot.context.config.StandardConfigDataLocationResolver.getReferencesForFile(StandardConfigDataLocationResolver.java:229)
at org.springframework.boot.context.config.StandardConfigDataLocationResolver.getReferences(StandardConfigDataLocationResolver.java:138)
... 32 common frames omitted
I don’t want to have multiple profiles or multiple application.yml I want to set consul state by ENV variables (true/false)
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (4 by maintainers)
Top Results From Across the Web
Config file processing in Spring Boot 2.4
1, some unit-tests started to fail, as they began to ignore src/test/resources/application.properties and use content from src/main/resources/ ...
Read more >Settings in application.yml for spring.cloud.config aren't used ...
The app try to get data from default uri(localhost) instead of to use uri from my setting. I've looked at app in debug...
Read more >Writing Client Applications - VMware Docs
Important: Because of a dependency on Spring Security, the Spring Cloud Config Client starter will by default cause all app endpoints to be ......
Read more >Dev-2-Deployment: Spring Cloud Config using GitLab with ...
yml file in the root of the project whose configuration will apply to all the applications and domains, irrespective of their name. Spring...
Read more >Spring Cloud Config for Shared Microservice Configuration
This tutorial shows how to use Spring Cloud config to manage configuration properties for multiple Spring Boot applications from a single ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Thx for your answer.
With
optional:consul:
andspring.cloud.consul.config.enabled=true
works as expected. Config was loaded from Consul.With
optional:consul:
andspring.cloud.consul.config.enabled=false
I have got a errorI expect that Spring Cloud Config will read config from my application.yml without errors like this
Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue.