錯誤描述:如下
***************************
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:
com.alibaba.dubbo.common.logger.LoggerFactory.setLoggerAdapter(LoggerFactory.java:86)
The following method did not exist:
com.alibaba.dubbo.common.logger.LoggerAdapter.getLogger(Ljava/lang/String;)Lcom/alibaba/dubbo/common/logger/Logger;
The method's class, com.alibaba.dubbo.common.logger.LoggerAdapter, is available from the following locations:
jar:file:/C:/Users/Administrator/.m2/repository/org/apache/dubbo/dubbo/2.7.6/dubbo-2.7.6.jar!/com/alibaba/dubbo/common/logger/LoggerAdapter.class
jar:file:/C:/Users/Administrator/.m2/repository/com/alibaba/dubbo/2.4.10/dubbo-2.4.10.jar!/com/alibaba/dubbo/common/logger/LoggerAdapter.class
It was loaded from the following location:
file:/C:/Users/Administrator/.m2/repository/org/apache/dubbo/dubbo/2.7.6/dubbo-2.7.6.jar
Action:
Correct the classpath of your application so that it contains a single, compatible version of com.alibaba.dubbo.common.logger.LoggerAdapter
我這裏就是:同時引入了:com.alibaba.dubbo和org.apache.dubbo,項目進行日誌管理,LoggerFactory使用的時候使用的org相關的,但是需要的是com.alibaba.dubbo相關,當然在類似錯誤中也是同理,即:同時引入同類型的JAR,默認使用的不是我們想要的
解決方案:
假設我們同時引入了A,B,但不需要使用A,則在引入A的pom中exclusion就好了,一般這種都是出現在,一個是顯式引入,一個是依賴的二方包引入,在後者裏排除即可。
舉例:
pom中我們同時引入了A,B,同時A裏面引入了C,但是C和我們的B衝突了,此時只需要在A的pom中exclusion就行,如下:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>A</artifactId>
<version>1.0.0</version>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>C</artifactId>
</exclusion>
</exclusions>
</dependency>