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方法找不到,
我点进去看源码发现:
concat报红。实际上是:com.google.common.collect.FluentIterable类中的concat方法找不到
为什么会报这种错误,查看maven依赖发现:
这里引用的是guava18.0版本的jar包。我这里swagger的依赖是:
<!-- https://mvnrepository.com/artifact/io.springfox/springfox-swagger2 -->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.9.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/io.springfox/springfox-swagger-ui -->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.9.2</version>
</dependency>
全局查看FluentIterable类中其实并没有该方法:那就肯定是版本不对。可是swagger2.9.2默认引入的h为什么是18.0这就不得而知了?所以我网上搜索guava/FluentIterable中存在cotcan方法相对的版本?查看maven仓库找到guava最新版本28.0直接引入
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>28.0-jre</version>
</dependency>
问题解决--