问题:
***************************
APPLICATION FAILED TO START
***************************
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:/software/maven399/localRepository/com/google/guava/guava/18.0/guava-18.0.jar!/com/google/common/collect/FluentIterable.class
The class hierarchy was loaded from the following locations:
com.google.common.collect.FluentIterable: file:/D:/software/maven399/localRepository/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解决办法:
这个问题的核心是在你的应用程序中,FluentIterable 类的版本不兼容。错误提示显示 springfox.documentation.schema.DefaultModelDependencyProvider.dependentModels 方法尝试调用一个在当前版本的 Guava 库中不存在的方法。
解决步骤:
- 查看 Guava 版本:
错误信息中显示当前使用的 Guava 版本是 18.0,这个版本可能缺少FluentIterable.concat()方法。你需要确保使用一个包含该方法的版本。通常,FluentIterable.concat()方法是在 Guava 19.0 版本后才被引入的。 更新 Guava 版本:
你可以尝试将项目中的 Guava 版本更新到更高的版本,至少是 19.0 及以上版本。比如,如果你在使用 Maven,可以在pom.xml中更新 Guava 依赖:<dependency> <groupId>com.google.guava</groupId> <artifactId>guava</artifactId> <version>30.1-jre</version> <!-- 你可以选择最新的版本 --> </dependency>检查依赖冲突:
有时,项目中可能存在多个不同版本的 Guava,导致类路径冲突。你可以使用mvn dependency:tree来查看项目的依赖树,确保只有一个版本的 Guava。如果有多个版本,可以通过dependencyManagement来强制使用统一的版本:<dependencyManagement> <dependencies> <dependency> <groupId>com.google.guava</groupId> <artifactId>guava</artifactId> <version>30.1-jre</version> </dependency> </dependencies> </dependencyManagement>- 清理并重新构建:
更新依赖后,执行 Maven 清理和重新构建操作:
mvn clean install检查 Springfox 版本:
有时这个问题可能与 Springfox 版本不兼容有关。确保你使用的 Springfox 版本与你的 Spring Boot 版本兼容。如果 Springfox 版本过低,可以尝试升级到更高版本。<dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger2</artifactId> <version>2.9.2</version> <!-- 或者更高版本 --> </dependency>
总结
- 确保 Guava 库版本 >= 19.0。
- 检查项目中是否有 Guava 版本冲突。
- 确保 Springfox 与 Spring Boot 版本兼容。
如果问题依然存在,尝试逐步排查其他可能的依赖问题。


Comments | NOTHING