java连接hadoop报错: Caused by: java.lang.IllegalArgumentException: LoggerFactory is not a Logback Logger

Caused by: java.lang.IllegalArgumentException: LoggerFactory is not a Logback LoggerContext but Logback is on the classpath. Either remove Logback or the competing implementation (class org.slf4j.impl.Log4jLoggerFactory loaded from file:/usr/local/tomcat/webapps/hadoop/WEB-INF/lib/slf4j-log4j12-1.7.26.jar). If you are using WebLogic you will need to add 'org.slf4j' to prefer-application-packages in WEB-INF/weblogic.xml: org.slf4j.impl.Log4jLoggerFactory
是maven加载hadoop的依赖包之后,启动项目出现了以上异常
这个异常是jar包的冲突,删除掉slf4j-log4j12-1.7.26.jar就可以了
我们在maven依赖中对hadoop-hdfs和hadoop-client的依赖都去除slf4j-log4j12依赖即可

     
        org.springframework.boot
        spring-boot-starter-web
        
            
                org.springframework.boot
                spring-boot-starter-logging
            
        

    

    
        org.springframework.boot
        spring-boot-starter
        
            
                org.springframework.boot
                spring-boot-starter-logging
            
        
    

    
        org.projectlombok
        lombok
        true
    

    

    
        org.springframework.boot
        spring-boot-starter-test
        test
    

    
        org.apache.hadoop
        hadoop-common
        3.1.1
        
            
                org.slf4j
                slf4j-log4j12
            
        
    
    
        org.apache.hadoop
        hadoop-hdfs
        3.1.1
        
            
                org.slf4j
                slf4j-log4j12
            
        
    
    
        org.apache.hadoop
        hadoop-client
        3.1.1
        
            
                org.slf4j
                slf4j-log4j12
            
        
    
    
        org.apache.hadoop
        hadoop-mapreduce-client-core
        3.1.1
    

java连接hadoop报错: Caused by: java.lang.IllegalArgumentException: LoggerFactory is not a Logback Logger_第1张图片
java连接hadoop报错: Caused by: java.lang.IllegalArgumentException: LoggerFactory is not a Logback Logger_第2张图片
java连接hadoop报错: Caused by: java.lang.IllegalArgumentException: LoggerFactory is not a Logback Logger_第3张图片
我的项目是部署在linux中的docker上的,然后重新打包运行,启动成功了
java连接hadoop报错: Caused by: java.lang.IllegalArgumentException: LoggerFactory is not a Logback Logger_第4张图片

你可能感兴趣的:(java,hadoop)