LoggerFactory不是Logback LoggerContext,但Logback在类路径上

new*_*bie 9 java logging spring-security dependency-management spring-boot

我认为spring-boot-starter-security中的一些模块与log4j冲突,但我不知道哪一个.

我的依赖关系如下:

compile("org.springframework.boot:spring-boot-starter-thymeleaf")
compile("org.springframework.boot:spring-boot-starter-security"){
    exclude module: "spring-boot-starter-logging"
}

compile "org.apache.logging.log4j:log4j-api"
compile "org.apache.logging.log4j:log4j-core"
compile "org.apache.logging.log4j:log4j-slf4j-impl"
compile('org.apache.poi:poi:3.10.1')
compile('org.apache.poi:poi-ooxml:3.10.1')
testCompile("junit:junit")
Run Code Online (Sandbox Code Playgroud)

rup*_*web 20

我的问题是:删除 Logback 或从 log4j-slf4j-impl-2.12.0.jar 加载的竞争实现类 org.apache.logging.slf4j.Log4jLoggerFactory

我加了

configurations {
    all {
        exclude group: 'org.springframework.boot', module: 'spring-boot-starter-logging'
        exclude group: 'ch.qos.logback', module: 'logback-classic'
        exclude group: 'org.apache.logging.log4j', module: 'log4j-to-slf4j'
    }
}
Run Code Online (Sandbox Code Playgroud)

到我的 gradle.build 并使用最新版本刷新所有项目依赖项,问题已解决。


ufu*_*mer 15

maven的相同解决方案:

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-thymeleaf</artifactId>
    <version>1.5.1.RELEASE</version>
    <exclusions>
        <exclusion>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-classic</artifactId>
        </exclusion>
    </exclusions>
</dependency>
Run Code Online (Sandbox Code Playgroud)


new*_*bie 11

我想通了

compile("org.springframework.boot:spring-boot-starter-security"){
    exclude module: "spring-boot-starter-logging"
    exclude module: "logback-classic"
}
compile("org.springframework.boot:spring-boot-starter-thymeleaf"){
    exclude module: "logback-classic"
}
Run Code Online (Sandbox Code Playgroud)


Rob*_*ang 9

使用 IDEA“显示依赖项”或mvn dependency:tree -Dverbose查找所有 logback-classic jar 文件,并排除它们。


Ana*_*kzz 7

包含后开始看到此错误'it.ozimov:embedded-redis:0.7.3'我必须更改

testImplementation 'it.ozimov:embedded-redis:0.7.3'
Run Code Online (Sandbox Code Playgroud)

testImplementation ('it.ozimov:embedded-redis:0.7.3') {
    exclude module: 'commons-logging'
    exclude module: 'slf4j-simple'
}
Run Code Online (Sandbox Code Playgroud)

问题已解决。


raz*_*ang 5

            <exclusions>
                <exclusion>
                    <groupId>org.slf4j</groupId>
                    <artifactId>slf4j-simple</artifactId>
                </exclusion>
            </exclusions>
Run Code Online (Sandbox Code Playgroud)

对我来说,这就是解决方案,因为 OpenAPI Generator 带来了这个,并且它与 SpringsBoot 默认值冲突。一旦我排除了这个,SpringBootApp 就开始工作了。