美文网首页
Could not resolve placeholder 'x

Could not resolve placeholder 'x

作者: 拄杖忙学轻声码 | 来源:发表于2021-07-25 04:34 被阅读0次

nacos读取不到配置中心属性,报错Could not resolve placeholder 'xxx' in value "${xxx.xxx}",一般原因有二:
一、没有引入nacos config依赖导致的:

    <!-- spring cloud starter alibaba nacos config
         加入这个配置中心的依赖后,需要使用bootstrap.yml作为配置文件,配置读取优先级 bootstrap.yml > application.yml
     -->
    <dependency>
      <groupId>com.alibaba.cloud</groupId>
      <artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
    </dependency>

二、bootstrap.yml配置文件中配置中心地址结尾不能带斜杠/,如下正确的配置:

config:
        server-addr: http://localhost:8848   # nacos配置中心地址,注意:结尾不能带斜杠/
        group: TEST_GROUP   # 指定分组名
        file-extension: yaml  # 指定yaml格式的文件配置

说明:还有配置文件命名规则一定要注意:

# 配置中心文件命名规则
# ${prefix}:服务名称、${spring.profiles.active}:激活的环境标识、${file-extension}:后缀名称

相关文章

网友评论

      本文标题:Could not resolve placeholder 'x

      本文链接:https://www.haomeiwen.com/subject/ucsbmltx.html