最終的pom.xml
<dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger2</artifactId> <version>2.9.2</version> </dependency> <dependency> <groupId>com.google.guava</groupId> <artifactId>guava</artifactId> <version>27.1-jre</version> </dependency>
問題:
***************************
APPLICATION FAILED TO START
***************************
Description:
An attempt was made to call the method com.google.common.collect.Multimaps.asMap(Lcom/google/common/collect/ListMultimap;)Ljava/util/Map; but it does not exist. Its class, com.google.common.collect.Multimaps, is available from the following locations:
jar:file:/opt/jzy/pytha-0.0.1-SNAPSHOT.jar!/BOOT-INF/lib/hive-exec-1.2.1.jar!/com/google/common/collect/Multimaps.class
jar:file:/opt/jzy/pytha-0.0.1-SNAPSHOT.jar!/BOOT-INF/lib/guava-20.0.jar!/com/google/common/collect/Multimaps.class
It was loaded from the following location:
jar:file:/opt/jzy/pytha-0.0.1-SNAPSHOT.jar!/BOOT-INF/lib/hive-exec-1.2.1.jar!/
Action:
Correct the classpath of your application so that it contains a single, compatible version of com.google.common.collect.Multimaps
1.一看就是jar衝突 首先想到的是pom文件中去掉hive-exec-1.2.1,但是我的pom文件中就沒有依賴它,代碼中也沒有用到
於是使用idea中的project structure > Libraries 去掉hive-exec-1.2.1 再次運行還是報錯,再次查看project structure > Libraries
hive-exec-1.2.1 依然存在,想着用修改pom文件中的方式解決。
2.查看hive-exec-1.2.1(guava16)中引用的guava版本與springfox-swagger2(guava20)中引用的guava版本區別很大,這個時候想到hive-exec-1.2.1,我根本沒用,但是他還是加載,百度了一下說pom添加guava-20.0依賴,去掉其他的guava,試了一下還是報錯。
3.查看springfox-swagger2引用時看到有個更新27.1-jre版本於是添加依賴,沒有做排除如上面的依賴一樣,但是還是做了idea中的project structure > Libraries 去掉hive-exec-1.2.1 再次運行沒有問題了,再次查看project structure > Libraries hive-exec-1.2.1 不存在了