背景介绍
我用的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>