项目引入 swagger 启动报错处理(An attempt was made to call the method com.google.common.collect.FluentIterable)

背景介绍

我用的springboot框架,是用maven构建的项目,加入swagger依赖的时候启动的时候报错

报错信息:


***************************
APPLICATION FAILED TO START
***************************

Description:

An attempt was made to call the method com.google.common.collect.FluentIterable.concat(Ljava/lang/Iterable;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:/repository/com/google/guava/guava/19.0/guava-19.0.jar!/com/google/common/collect/FluentIterable.class

It was loaded from the following location:

    file:/repository/com/google/guava/guava/19.0/guava-19.0.jar


Action:

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


Process finished with exit code 0

定位原因:

根据错误定位是jar包冲突,

1、执行maven命令查看项目jar包依赖关系

mvn dependency:tree >tree.log

2、依赖引用分析发现有多个地方引用了guava

--nacos-client

--swagger

解决方案:

在启动项目模块中pom.xml 指定guava版本,重新启动项目。

         <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
            <version>29.0-jre</version>
        </dependency>

 

 

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值