当前位置: 代码网 > it编程>编程语言>Java > idea项目启动报错,日志包冲突slf4j和logback冲突问题

idea项目启动报错,日志包冲突slf4j和logback冲突问题

2024年10月01日 Java 我要评论
idea项目启动报错,日志包冲突slf4j和logback冲突报错如下slf4j: found binding in [jar:file:/e:/maven_dev/maven_3/apache-ma

idea项目启动报错,日志包冲突slf4j和logback冲突

报错如下

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.3.jar!/org/slf4j/impl/staticloggerbinder.class] 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.29.jar!/org/slf4j/impl/staticloggerbinder.class] 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:/e:/maven_dev/maven_3/apache-maven-3.5.2/repo/org/slf4j/slf4j-log4j12/1.7.29/slf4j-log4j12-1.7.29.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

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.3.jar!/org/slf4j/impl/staticloggerbinder.class]
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.29.jar!/org/slf4j/impl/staticloggerbinder.class]

在pom.xml中添加

<dependency>
    <groupid>ch.qos.logback</groupid>
    <artifactid>logback-classic</artifactid>
    <version>1.2.3</version>
</dependency>
<dependency>
    <groupid>org.springframework.boot</groupid>
    <artifactid>spring-boot-starter-web</artifactid>
    <!--解决日志包冲突-->
    <exclusions>
        <exclusion>
            <groupid>org.slf4j</groupid>
            <artifactid>slf4j-log4j12</artifactid>
        </exclusion>
    </exclusions>
</dependency>

根据自己的版本进行调整

<!--添加zookeeper版本,与虚拟机一致-->
        <dependency>
            <groupid>org.apache.zookeeper</groupid>
            <artifactid>zookeeper</artifactid>
            <version>3.4.9</version>
            <exclusions>
                <exclusion>
                    <groupid>org.slf4j</groupid>
                    <artifactid>slf4j-log4j12</artifactid>
                </exclusion>
            </exclusions>
        </dependency>

启动ok!!!

总结

以上为个人经验,希望能给大家一个参考,也希望大家多多支持代码网。

(0)

相关文章:

版权声明:本文内容由互联网用户贡献,该文观点仅代表作者本人。本站仅提供信息存储服务,不拥有所有权,不承担相关法律责任。 如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 2386932994@qq.com 举报,一经查实将立刻删除。

发表评论

验证码:
Copyright © 2017-2025  代码网 保留所有权利. 粤ICP备2024248653号
站长QQ:2386932994 | 联系邮箱:2386932994@qq.com