I try to use Consul as configuration server with Spring boot. I already succeed to use the kv store of consul to fetch variables, but now I want to be able to fetch variables as YAML files. Here is my bootstrap.yaml :
spring:
cloud.consul:
host: localhost
port: 8500
config:
enabled: true
format: YAML
failFast: true
I put this config on consul on the path "/config/my.application.name/data" :
testspring: hello
And I try to reach this property using :
@Value("${testspring}")
... with no success. What am I missing here ? What is the good path for config on consul ?
Thanks
EDIT : It appears that the config is loaded on the value ${data} and that it is not parsed. The data="testspring: hello", which is not what is expected.
I was able to fetch data using your sample. But if I remove format: YAML
(so use default KEY_VALUE) from my config then not parsed data
property is fetched. Maybe double check your bootstrap.yml
config for correct indentations.
What version of Spring Boot and Spring Cloud you are using ?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.