spring-cloud / spring-cloud-consul

Spring Cloud Consul
http://cloud.spring.io/spring-cloud-consul/
Apache License 2.0
813 stars 541 forks source link

Unable to configure Spring Cloud Consul for specific profiles #779

Closed arjpaiva closed 1 year ago

arjpaiva commented 2 years ago

Describe the bug I'm trying to configure spring cloud consul for a specific profile but when I try to run the application I get the following error:

***************************
APPLICATION FAILED TO START
***************************

Description:

Config data location 'consul:' does not exist

Action:

Check that the value 'consul:' at class path resource [application-local.properties] - 6:22 is correct, or prefix it with 'optional:'

Process finished with exit code 1

If I update spring.config.import to spring.config.import=optional:consul: in application-local.properties, consul configuration is ignored and the configuration from the properties file is used instead of consul.

application.properties: spring.cloud.consul.enabled=false

application-local.properties:

spring.cloud.consul.enabled=true
spring.config.import=consul:

spring.cloud.consul.config.enabled=true
spring.cloud.consul.config.watch.enabled=true
spring.cloud.consul.config.watch.delay=6000
spring.cloud.consul.config.watch.wait-time=1
spring.cloud.consul.config.profile-separator=_

It seems that Spring is not overriding the default configuration with the one specified in application-local.properties. I also tried configuring consul in bootstrap.properties and bootstrap-local.properties but I got the following error:

***************************
APPLICATION FAILED TO START
***************************

Description:

No spring.config.import property has been defined

Action:

Add a spring.config.import=consul: property to your configuration.
    If configuration is not required add spring.config.import=optional:consul: instead.
    To disable this check, set spring.cloud.consul.config.enabled=false or 
    spring.cloud.consul.config.import-check.enabled=false.

I'm using org.springframework.cloud:spring-cloud-starter-consul-config:3.0.3 and spring boot 2.4.7

Thank you in advance.

spencergibb commented 1 year ago

All spring.config.import statements are evaluated, never overridden.

spring-cloud-issues commented 1 year ago

If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.

spring-cloud-issues commented 1 year ago

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.