最开始运行时报错
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>
网友评论