zoukankan      html  css  js  c++  java
  • springcloud config配置采坑 Could not resolve placeholder 'from' in value "${from}报错,巨坑!

    最经在搭建springcloud config配置中心的时候,发现一切配置都配置正确了,但是microservice-config-client客户端一直启动报错:org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'configClientController': Injection of autowired dependencies failed; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'from' in value "${from}"
    如下:

     

     

    找了两天都没发现错了哪里,结果发现,是github上的仓库里的microservice-dev.yml配置文件名有问题,识别不了yml格式的,设置成properties类型就可以了,巨坑!

     

     修改好后如下:

    然后访问 http://localhost:8081/from 就可以了



    yml配置:
    microservice-config-server服务端配置
    server:
      port: 8080
    spring:
      application:
        name: microservice-config-server
      cloud:
        config:
          server:
            git:
              # Git仓库地址
              uri: https://github.com/Linliquan/spring-cloud-config-repo.git
              search-paths: config-repo
              # Git仓库账号
              username: Linliquan
              # Git仓库密码
              password: xxxxx
    eureka:
      client:
        service-url:
          defaultZone: http://localhost:8761/eureka/

    microservice-config-client客户端配置
    spring:
      application:
        name: microservice-client    # 对应config server所获取的配置文件的{application}
      cloud:
        config:
          name: microservice
          uri: http://localhost:8080/
          profile: dev            # profile对应config server所获取的配置文件中的{profile} 
          label: master           # 指定Git仓库的分支,对应config server所获取的配置文件的{label}

    microservice-config-client客户端restful API调用:
    @RestController
    public class ConfigClientController {
    
      @Value("${from}")
      private String from;
    
      @GetMapping("/from")
      public String hello() {
        return this.from;
      }
    
    }
  • 相关阅读:
    python绘制图的度分布柱状图, draw graph degree histogram with Python
    一波儿networkx 读写edgelist,给节点加attribute的操作
    Graph Convolutional Network
    C++ | 使用成员初始化列表对成员数据初始化
    C++ | 运算符new和delete
    C++ | 强制类型转换
    C++ | 作用域运算符“::”
    C++ | 内联函数 inline
    VS DEBUG
    消息中间件 | 消息协议 | AMQP -- 《分布式 消息中间件实践》笔记
  • 原文地址:https://www.cnblogs.com/linliquan/p/13033238.html
Copyright © 2011-2022 走看看