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

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

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

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

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

spring:
  application:
    name: ms-config-server
  profiles:
    active: native
  cloud:
    config:
      server:
        native:
          #window环境下用 D:/config
          #linux 环境下统一用 /config
          search-locations: E:\workspace\config

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