美文网首页
Error creating bean with name 'h

Error creating bean with name 'h

作者: 索性流年 | 来源:发表于2020-07-22 16:10 被阅读0次

    最开始运行时报错

    bean of type 'com.netflix.client.config.IClientConfig' that could not be found.
    
    • 在网上查找方法 创建 RibbonConfiguration 类继承 IClientConfig
    • 这个类是不能创建的,项目可以正常运行,可一旦用手 Fegin 客户端调用就会报空指针异常,返回的 message 如下
    Error creating bean with name 'httpClientConnectionManager' defined in 
    org.springframework.cloud.netflix.ribbon.apache.HttpClientRibbonConfiguration$ApacheHttpClientConfiguration: 
    Bean instantiation via factory method failed; nested exception is 
    org.springframework.beans.BeanInstantiationException: Failed to instantiate 
    [org.apache.http.conn.HttpClientConnectionManager]: Factory method 'httpClientConnectionManager' threw 
    exception; nested exception is java.lang.NullPointerException
    

    错误原因

    • 报这个错误是因为使用Nacos注册中心时 引入的依赖有关
    <dependency>
        <groupId>com.alibaba.cloud</groupId>
        <artifactId>spring-cloud-alibaba-nacos-discovery</artifactId>
        <version>2.1.1.RELEASE</version>
    </dependency>
    

    将依赖改为

    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
        <version>0.9.0.RELEASE</version>
    </dependency>
    

    问题解决

    相关文章

      网友评论

          本文标题:Error creating bean with name 'h

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