zuul 里面会引入 guava 的jar 包,默认版本是18
业务系统A中又引入了一个三方包,三方包中也引入guava 的jar 包,版本是比18更低的版本
现在的问题在于,业务系统A 中通过zuul 路由的时候,引用了 guava 的一个低版本,导致 高版本中的方法调用不到,提示:
NoSuchMethodFound
- Exception encountered during context initialization - cancelling refresh attempt:
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with
name 'ribbonLoadBalancingHttpClient' defined in
org.springframework.cloud.netflix.ribbon
.RibbonClientConfiguration$HttpClientRibbonConfiguration:
Unsatisfied dependency expressed through method 'ribbonLoadBalancingHttpClient' parameter
2; nested exception is org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'ribbonLoadBalancer' defined in
org.springframework.cloud.netflix.ribbon.RibbonClientConfiguration:
Bean instantiation via factory method failed; nested exception is
org.springframework.beans.BeanInstantiationException: Failed to instantiate
[com.netflix.loadbalancer.ILoadBalancer]:
Factory method 'ribbonLoadBalancer' threw exception;
nested exception is java.lang.NoSuchMethodError: com.google.common.base.Platform.systemNanoTime()J
而这两个依赖jar 包都不能少,最后的一个解决办法就是:
把三方包中引入的低版本的guava 去掉。
具体操作是:将jar 文件解压,然后删除其中涉及到guava 的部分,重新打包成 jar ,再引入业务系统即可。
将文件夹打包成jar 文件可以参考:将文件夹打成jar 包