pringboot2集成swagger2出现guava的FluentIterable方法不存在

文章讲述了在使用Springfox和Swagger时遇到的错误,由于不同版本依赖导致FluentIterable中的方法不存在。解决方法包括删除不必要的swagger-springmvc依赖或升级Guava到对应版本28.0。
摘要由CSDN通过智能技术生成

错误信息

Description:

An attempt was made to call a method that does not exist. The attempt was made from the following location:

    springfox.documentation.spring.web.scanners.ApiListingScanner.scan(ApiListingScanner.java:117)

The following method did not exist:

    com.google.common.collect.FluentIterable.append(Ljava/lang/Iterable;)Lcom/google/common/collect/FluentIterable;

The method's class, com.google.common.collect.FluentIterable, is available from the following locations:

    jar:file:/D:/apache-maven-3.8.1/repository/com/google/guava/guava/15.0/guava-15.0.jar!/com/google/common/collect/FluentIterable.class

It was loaded from the following location:

    file:/D:/apache-maven-3.8.1/repository/com/google/guava/guava/15.0/guava-15.0.jar


Action:

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

Disconnected from the target VM, address: '127.0.0.1:51641', transport: 'socket'

 错误是因为    springfox.documentation.spring.web.scanners.ApiListingScanner.scan  中使用了FluentIterable.apend方法,但是这个方法不存在。这样的原因肯定是版本不对到导致的。

我的swagger依赖是

<!--swagger-->
<dependency>
    <groupId>com.spring4all</groupId>
    <artifactId>swagger-spring-boot-starter</artifactId>
    <version>1.9.1.RELEASE</version>
</dependency>
<dependency>
    <groupId>com.mangofactory</groupId>
    <artifactId>swagger-springmvc</artifactId>
    <version>0.9.5</version>
</dependency>

原因是我的 swagger-springmvc  版本不对,0.9.5最终引用的guava版本是15.0。但是我的springfox相关依赖都是2.9.2的,导致版本对应不上。

解决方法:

一:因为我不需要 swagger-springmvc  ,所以可以删除这个依赖。

二:如果一定需要使用 swagger-springmvc ,则可以在网上搜索guava/FluentIterable中存在cotcan方法相对的版本?查看maven仓库找到guava最新版本28.0直接引入。

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值