spring cloud config取不到配置@Value报错: Could not resolve placeholder 'xxxx' in value

原创 2020-01-02 11:28 阅读(12074)次

我们项目是使用spring cloud config作为微服务配置管理,使用的是本地文件形式,今天我重新下载了一份配置,修改了配置服务的文件地址,然后config client的项目就启动不了了,一直报错:

Could not resolve placeholder 'xxxx' in value "${xxxx}"

开始以为是项目配置格式问题,后来想到应该是我改了config server的配置地址:

  1. spring:
  2. application:
  3. name: ms-config-server
  4. profiles:
  5. active: native
  6. cloud:
  7. config:
  8. server:
  9. native:
  10. #window环境下用 D:/config
  11. #linux 环境下统一用 /config
  12. search-locations: E:\workspace\config

检查了下,觉得是不是search-locations中的反斜杠问题,改成/,发现就可以了,所以说spring cloud config配置要求还是很严格的,不仅yml格式要注意,文件地址还不能用反斜杠。。。坑