启动报错-重复引用jar包
报错信息:
***************************
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.spring.web.scanners.ApiListingReferenceScanner.scan(ApiListingReferenceScanner.java:59)
The following method did not exist:
com.google.common.collect.Multimaps.asMap(Lcom/google/common/collect/ListMultimap;)Ljava/util/Map;
The method's class, com.google.common.collect.Multimaps, is available from the following locations:
jar:file:/usr/local/tomcat/webapps/ROOT/WEB-INF/lib/hive-exec-1.1.0-cdh5.14.0.jar!/com/google/common/collect/Multimaps.class
jar:file:/usr/local/tomcat/webapps/ROOT/WEB-INF/lib/guava-20.0.jar!/com/google/common/collect/Multimaps.class
It was loaded from the following location:
file:/usr/local/tomcat/webapps/ROOT/WEB-INF/lib/hive-exec-1.1.0-cdh5.14.0.jar
Action:
Correct the classpath of your application so that it contains a single, compatible version of com.google.common.collect.Multimaps
Caused by: org.springframework.context.ApplicationContextException: Failed to start bean 'documentationPluginsBootstrapper'; nested exception is java.lang.NoSuchMethodError: com.google.common.collect.Multimaps.asMap(Lcom/google/common/collect/ListMultimap;)Ljava/util/Map;
根据日志信息可以明白,有两个地方引用了jar包中的某个方法(/com/google/common/collect/Multimaps.class),归根到底就是重复引用了jar包。通过在项目中查看jar包依赖关系,根据实际需要去掉一个jar包依赖即可。当然报错日志肯定不止这点,但后续的报错都是因为jar包重复引用导致的,找到主要问题并解决就行了。
解决:
日志中提示了jar包:hive-exec-1.1.0-cdh5.14.0.jar 和 guava-20.0.jar,而 hive-exec-1.1.0-cdh5.14.0.jar 中包含了 guava-20.0.jar ,那么,这里直接去掉后者的依赖即可。
啥,你以为就这样就完了吗?我遇到的可是一大堆报错哦!
哦,不是啊!啥?你也遇到很多报错啊!来看看下面这个报错及解决汇总文章: