SoFunction
Updated on 2025-03-02

Idea project start error, log package conflict problem slf4j and logback conflict problem

Idea project start error, log package conflicts slf4j and logback conflicts

The error is as follows

SLF4J: Found binding in [jar:file:/E:/maven_dev/maven_3/apache-maven-3.5.2/repo/ch/qos/logback/logback-classic/1.2.3/logback-classic-1.2.!/org/slf4j/impl/] SLF4J: Found binding in [jar:file:/E:/maven_dev/maven_3/apache-maven-3.5.2/repo/org/slf4j/slf4j-log4j12/1.7.29/slf4j-log4j12-1.7.!/org/slf4j/impl/] Caused by: : LoggerFactory is not a Logback LoggerContext but Logback is on the classpath. Either remove Logback or the competing implementation (class org..Log4jLoggerFactory loaded from file:/E:/maven_dev/maven_3/apache-maven-3.5.2/repo/org/slf4j/slf4j-log4j12/1.7.29/slf4j-log4j12-1.7.). If you are using WebLogic you will need to add 'org.slf4j' to prefer-application-packages in WEB-INF/: org..Log4jLoggerFactory

SLF4J: Found binding in [jar:file:/E:/maven_dev/maven_3/apache-maven-3.5.2/repo/ch/qos/logback/logback-classic/1.2.3/logback-classic-1.2.!/org/slf4j/impl/]
SLF4J: Found binding in [jar:file:/E:/maven_dev/maven_3/apache-maven-3.5.2/repo/org/slf4j/slf4j-log4j12/1.7.29/slf4j-log4j12-1.7.!/org/slf4j/impl/]

Add in

<dependency>
    <groupId></groupId>
    <artifactId>logback-classic</artifactId>
    <version>1.2.3</version>
</dependency>
&lt;dependency&gt;
    &lt;groupId&gt;&lt;/groupId&gt;
    &lt;artifactId&gt;spring-boot-starter-web&lt;/artifactId&gt;
    &lt;!--Resolve log package conflicts--&gt;
    &lt;exclusions&gt;
        &lt;exclusion&gt;
            &lt;groupId&gt;org.slf4j&lt;/groupId&gt;
            &lt;artifactId&gt;slf4j-log4j12&lt;/artifactId&gt;
        &lt;/exclusion&gt;
    &lt;/exclusions&gt;
&lt;/dependency&gt;

Adjust according to your version

&lt;!--Add tozookeeperVersion,Consistent with the virtual machine--&gt;
        &lt;dependency&gt;
            &lt;groupId&gt;&lt;/groupId&gt;
            &lt;artifactId&gt;zookeeper&lt;/artifactId&gt;
            &lt;version&gt;3.4.9&lt;/version&gt;
            &lt;exclusions&gt;
                &lt;exclusion&gt;
                    &lt;groupId&gt;org.slf4j&lt;/groupId&gt;
                    &lt;artifactId&gt;slf4j-log4j12&lt;/artifactId&gt;
                &lt;/exclusion&gt;
            &lt;/exclusions&gt;
        &lt;/dependency&gt;

Start OK!!!

Summarize

The above is personal experience. I hope you can give you a reference and I hope you can support me more.