项目依赖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:

    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就行,如下:


     org.springframework.boot
     A
     1.0.0
        
          
             org.junit.vintage
             C
          
        

 

你可能感兴趣的:(自学工具,Java基础)