springcloud的服务网关zuul,报错:
com.netflix.zuul.exception.ZuulException: Error creating bean with name ‘connPoolFactory’ defined in org.springframework.cloud.commons.httpclient.HttpClientConfiguration$OkHttpClientConfiguration: Post-processing of merged bean definition failed; nested exception is java.lang.NoClassDefFoundError: okhttp3/ConnectionPool
问题分析:
出现这类Error creating bean with name…这类的,我遇到的情况基本上就是两种情况:
①缺少bean注解,
②缺少相关依赖。
我的情况是第2种。
查看源码后发现确实没有okhttp3这个包,然而spring.cloud.commons这个包是需要导入okhttp3这个包的。如下图所示:
解决办法
因此解决办法也就很明朗了,在项目的pom.xml依赖中加入okhttp3的依赖就解决问题了:
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
<version>3.6.0</version>
</dependency>