Maven Spring Boot Failed to instantiate SLF4J LoggerFactory Reported exception:

后端 未结 7 2199
再見小時候
再見小時候 2021-02-15 15:22

I am following the tutorial https://spring.io/guides/gs/actuator-service/

And when I try to run the App I get:

Failed to instantiate SLF4J LoggerF

相关标签:
7条回答
  • 2021-02-15 15:44

    I add this dependency and problem resolved.

    <dependency>
        <groupId>ch.qos.logback</groupId>
        <artifactId>logback-core</artifactId>
        <version>${logback.version}</version>
    </dependency>
    

    you just use version of logback-classic if this error occurred.

    0 讨论(0)
  • 2021-02-15 15:48

    The issue does not exists with version 1.3.5. I changed my version to

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.3.5.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    

    It works !!

    0 讨论(0)
  • 2021-02-15 15:53

    We can skip logging dependency and it will work for us.

    `<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-web</artifactId>
    <exclusions>
    <exclusion>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-logging</artifactId>
    </exclusion>
    </exclusions>
    </dependency>`
    
    0 讨论(0)
  • 2021-02-15 16:00

    It may be a version problem, I change my version of springboot from 2.0.0.RELEASE to 1.5.4.RELEASE, the exception disappeared.

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.5.4.RELEASE</version>
    </parent>
    
    0 讨论(0)
  • 2021-02-15 16:07

    You need to find log4j and add in your classpath.

    0 讨论(0)
  • 2021-02-15 16:08

    See that message: (you manage dependency duplicate, for dependency transitive, that cause dependency duplicate with differents versions)

    Class path contains multiple SLF4J bindings. SLF4J: Found binding in

    make a test if use IDE Eclipse

    short cut key: Shift+Ctrl+T

    that way you see what file has contains this class:

    SLF4J: Found binding in [jar:file:
    /C:/Users/Josh/.m2/repository/ch/qos/logback/logback-classic/1.1.7/logback-classic-1.1.7.jar!
    /org/slf4j/impl/StaticLoggerBinder.class]
    [jar:file:/C:/Users/Josh/.m2/repository/org/slf4j/slf4j-log4j12/1.7.21/slf4j-log4j12-1.7.21.jar!
    /org/slf4j/impl/StaticLoggerBinder.class]
    

    repeat class in

    slf4j-log4j12-1.7.21.jar
    logback-classic-1.1.7.jar
    

    find your same dependency and exclusion what don't you need in your project

    that way:

    <dependency>
    <groupId>org.seleniumhq.selenium</groupId>
    <artifactId>selenium-java</artifactId>
    <version>3.0.0-beta2</version>
    <scope>test</scope>
    <exclusions>
        <exclusion>
            <artifactId>xml-apis</artifactId>
            <groupId>xml-apis</groupId>
        </exclusion>
    </exclusions>
    

    that one example, change for your context

    0 讨论(0)
提交回复
热议问题