guava jar 包冲突:java.lang.NoSuchMethodError: com.google.common.base.Platform.systemNanoTime()J

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 包

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值