Resolving conflicts between Spring-boot-starter-logging and log4j

Source: Internet
Author: User
Tags log4j

The build project encountered an error because the company configured the check rule in Super-bom:

[ERROR] [XXX Enforcer Rules] Find duplicateclasses

Found in:
Org.apache.logging.log4j:log4j-slf4j-impl:jar:2.6.2:compile
Ch.qos.logback:logback-classic:jar:1.1.7:compile
Duplicate classes:
Org/slf4j/impl/staticmdcbinder.class
Org/slf4j/impl/staticmarkerbinder.class
Org/slf4j/impl/staticloggerbinder.class

I did not directly quote Logback-classic in the POM, see this error is ignorant, I did not quote this in the Pom ah.

Resolution process:

It is possible to find out which package is dependent on Logback-classic by IntelliJ Idea's package dependency. Operation: View->tool window->maven Projects, this button:

You can see the package dependency graph, which may be more complex and messy, and can be searched after Ctrl+f:

This blog has mentioned how to deal with this problem: http://blog.csdn.net/xudan1010/article/details/ 52890102, that is, use excusions to exclude spring-boot-starter dependence on spring-boot-starter-logging, and then introduce Log4j-slf4j-impl

        <dependency>            <groupId>org.springframework.boot</groupId>            <artifactId> spring-boot-starter</artifactid>            <exclusions>                <exclusion>                    <groupId> Org.springframework.boot</groupid>                    <artifactId>spring-boot-starter-logging</artifactId>                </exclusion>            </exclusions>        </dependency>

You can also use commands to see dependencies: MVN dependency:tree | grep log

Resolving conflicts between Spring-boot-starter-logging and log4j

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.