SLF4J NoSuchMethodError on LocationAwareLogger

前端 未结 8 1701

This is a question that has been asked before, but unfortunately no solution seems to work for me. I am facing this exception (with abridged stack trace):

ja         


        
相关标签:
8条回答
  • 2020-12-03 07:28

    This usually happens when you have dependencies that both use the same transitive dependency. This means that 2 of your dependencies (or your app, and a transitive dependency) are both using SLF4J internally with different versions. But your app can only use a single version of the class at the same time so it has to choose (don't know the rules here... random?)

    To solve the problem, you usually need to do a mvn dependency:tree to see which are using different versions of SLF4J.

    Adding this dependency solved the issue for me

    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-api</artifactId>
        <version>1.7.25</version>
    </dependency>
    
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-log4j12</artifactId>
        <version>1.7.5</version>
    </dependency>
    
    0 讨论(0)
  • 2020-12-03 07:30

    do

    mvn clean dependency:tree -DskipTests;

    remove all the dependencies of "org.slf4j" except one (highest one") as

        <dependency>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-jar-plugin</artifactId>
            <version>2.6</version>
            <exclusions>
                <exclusion>
                    <groupId>org.slf4j</groupId>
                    <artifactId>slf4j-jdk14</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.slf4j</groupId>
                    <artifactId>jcl-over-slf4j</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
    
    0 讨论(0)
提交回复
热议问题