Spring cloud config client property "spring.cloud.config.uri" has no effect, I see the source in class org.springframework.cloud.config.client.ConfigClientProperties
public ConfigClientProperties override(
org.springframework.core.env.Environment environment) {
ConfigClientProperties override = new ConfigClientProperties();
BeanUtils.copyProperties(this, override);
override.setName(
environment.resolvePlaceholders("${" + ConfigClientProperties.PREFIX
+ ".name:${spring.application.name:application}}"));
if (environment.containsProperty(ConfigClientProperties.PREFIX + ".profile")) {
override.setProfile(
environment.getProperty(ConfigClientProperties.PREFIX + ".profile"));
}
if (environment.containsProperty(ConfigClientProperties.PREFIX + ".label")) {
override.setLabel(
environment.getProperty(ConfigClientProperties.PREFIX + ".label"));
}
return override;
}
I see "profile" and "label" will override the config, but uri does not, is it right?
Are you setting the property in bootstrap.yml? A sample project might help.
You haven't explained what "no effect" means. Please describe your problem first with steps to reproduce or a sample project before trying to point out a bug.
My application.yml
server:
port: 8080
management:
context-path: /
logging:
level:
com.netflix.discovery: 'OFF'
org.springframework.cloud: 'DEBUG'
eureka:
instance:
leaseRenewalIntervalInSeconds: 10
statusPageUrlPath: /info
healthCheckUrlPath: /health
client:
serviceUrl:
defaultZone: ${eureka.addr}
feign:
hystrix:
enabled: true
spring:
application:
name: demo-service
cloud:
config:
label: master # optional
uri: http://localhost:8889 # optional
profile: ${spring.profiles.active}
zipkin:
baseUrl: ${zipkin.addr}
enabled: true
compression:
enabled: false
flush-interval: 1
sleuth:
feign:
enabled: true
spring.cloud.config.uri is set to localhost:8889, but when I startup, it still connnect to localhost:8888
Is it enough to find out the problem?
You need to set spring.cloud.config.uri in bootstrap.yml not application.yml.
From the documentation:
To modify the startup behaviour you can change the location of the config server using bootstrap.properties (like application.properties but for the bootstrap phase of an application context)
Thanks.I will try it.
You need to set
spring.cloud.config.uriinbootstrap.ymlnotapplication.yml.From the documentation:
To modify the startup behaviour you can change the location of the config server using bootstrap.properties (like application.properties but for the bootstrap phase of an application context)
It solved my issue
what needs to be done if I don't want to create a separate file and provide entry only in application.properties
From the documentation:
To modify the startup behaviour you can change the location of the config server using bootstrap.properties (like application.properties but for the bootstrap phase of an application context)
Most helpful comment
You need to set
spring.cloud.config.uriinbootstrap.ymlnotapplication.yml.From the documentation: