从Spring Boot访问yaml Consor配置
我尝试使用concur作为Spring引导的配置服务器。我已经成功地使用concur的kv存储来获取变量,但现在我希望能够将变量作为YAML文件获取。这是我的引导。yaml:从Spring Boot访问yaml Consor配置,spring,spring-boot,consul,spring-cloud-config,spring-cloud-consul,Spring,Spring Boot,Consul,Spring Cloud Config,Spring Cloud Consul,我尝试使用concur作为Spring引导的配置服务器。我已经成功地使用concur的kv存储来获取变量,但现在我希望能够将变量作为YAML文件获取。这是我的引导。yaml: spring: cloud.consul: host: localhost port: 8500 config: enabled: true format: YAML failFast: true 我将此配置放在concur的路径“/config/my.ap
spring:
cloud.consul:
host: localhost
port: 8500
config:
enabled: true
format: YAML
failFast: true
我将此配置放在concur的路径“/config/my.application.name/data”上:
我尝试通过以下方式访问此属性:
@Value("${testspring}")
。。。没有成功。
我错过了什么?在Consor上配置的好方法是什么
谢谢
编辑:
似乎配置是在值${data}上加载的,并且未对其进行分析。data=“testspring:hello”,这不是预期的结果。我能够使用您的示例获取数据。但如果我从配置中删除
format:YAML
(因此使用默认的KEY\u值),则会获取未解析的数据属性。
可能需要再次检查您的bootstrap.yml
config以获得正确的缩进
您正在使用哪个版本的Spring Boot和Spring Cloud
@Value("${testspring}")