springboot2集成swagger2出现guava包下的The following method did not exist:FluentIterable.class

Description:

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

    springfox.documentation.schema.DefaultModelDependencyProvider.dependentModels(DefaultModelDependencyProvider.java:79)

The following method did not exist:

    com.google.common.collect.FluentIterable.concat(Ljava/lang/Iterable;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.6.1/repository/com/google/guava/guava/18.0/guava-18.0.jar!/com/google/common/collect/FluentIterable.class

It was loaded from the following location:

    file:/D:/apache-maven-3.6.1/repository/com/google/guava/guava/18.0/guava-18.0.jar


Action:

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

先说明下这个错误,它是指springfox.documentation.schema.DefaultModelDependencyProvider类下的dependentModels方法找不到,

我点进去看源码发现:

springboot2集成swagger2出现guava包下的The following method did not exist:FluentIterable.class_第1张图片

concat报红。实际上是:com.google.common.collect.FluentIterable类中的concat方法找不到

为什么会报这种错误,查看maven依赖发现:

springboot2集成swagger2出现guava包下的The following method did not exist:FluentIterable.class_第2张图片

这里引用的是guava18.0版本的jar包。我这里swagger的依赖是:

 
        
            io.springfox
            springfox-swagger2
            2.9.2
        
        
        
            io.springfox
            springfox-swagger-ui
            2.9.2
        

全局查看FluentIterable类中其实并没有该方法:那就肯定是版本不对。可是swagger2.9.2默认引入的h为什么是18.0这就不得而知了?所以我网上搜索guava/FluentIterable中存在cotcan方法相对的版本?查看maven仓库找到guava最新版本28.0直接引入

springboot2集成swagger2出现guava包下的The following method did not exist:FluentIterable.class_第3张图片

        
            com.google.guava
            guava
            28.0-jre
        

问题解决--

你可能感兴趣的:(问题解决,java,springboot,maven)