Maven依赖冲突的两种解决方式

Description:

An attempt was made to call the method com.google.common.collect.FluentIterable.append(Ljava/lang/Iterable;)Lcom/google/common/collect/FluentIterable; but it does not exist. Its class, com.google.common.collect.FluentIterable, is available from the following locations:

    jar:file:/C:/Users/XXX/.m2/repository/com/google/guava/guava/16.0.1/guava-16.0.1.jar!/com/google/common/collect/FluentIterable.class

It was loaded from the following location:

    file:/C:/Users/XXX/.m2/repository/com/google/guava/guava/16.0.1/guava-16.0.1.jar


Action:

Correct the classpath of your application so that it contains a single, compatible version of com.google.common.collect.FluentIterable

背景:

在rabbon工程中加入swagger引发的错误。

环境:

spring-cloud-starter-netflix-ribbon Greenwich.RC2

swagger-spring-boot-starter 1.8.0.RELEASE

排查:

打开pom.xml文件,切换到dependency hierarchy

左侧为各jar包之间的关系视图,右侧为决定jar包版本的视图

在右侧找出报错的jar包名称,单击,左侧用到的会自动高亮,

然后我这边是因为swagger的guava.jar用到了20,决定性版本为16.0.1,不兼容所以出错了

如下图

 

解决方案1:统一版本

就是为jar包指定一个版本,所有用到的都会是这个版本

按图操作。。

然后ok,在pom.xml中就会对jar包指定版本,

应该可以改成其他版本吧?

搞定~

 

解决方案2:排除加载

就是在别的用到这个jar包的地方加上说明,告诉它不用自己加载依赖用别人的。

按图操作。。

 

这里可以看到它默认每个都排除加载了,那就是所以都不加载,那就是没有加载肯定报错,所以要去掉一个不用排除

 

搞定~

所以还是方案一方便...

评论 13
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值