Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/logging/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java LoggerFactory不是Logback LoggerContext,但Logback位于类路径上_Java_Logging_Spring Security_Spring Boot_Dependency Management - Fatal编程技术网

Java LoggerFactory不是Logback LoggerContext,但Logback位于类路径上

Java LoggerFactory不是Logback LoggerContext,但Logback位于类路径上,java,logging,spring-security,spring-boot,dependency-management,Java,Logging,Spring Security,Spring Boot,Dependency Management,我认为SpringBootStarter安全性中的某些模块与log4j冲突,但我不知道是哪一个 我的梯度依赖性如下: compile("org.springframework.boot:spring-boot-starter-thymeleaf") compile("org.springframework.boot:spring-boot-starter-security"){ exclude module: "spring-boot-starter-logging" } compil

我认为SpringBootStarter安全性中的某些模块与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")
我明白了

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"
}

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>

org.springframework.boot
弹簧启动装置
1.5.1.1发布
回写
回归经典

使用“显示依赖项”或
mvn依赖项:tree-Dverbose
的思想来查找所有的logback classic jar文件,并将其排除。

对我来说,这个问题只在执行maven surefire插件时出现。不管怎样,Logback在类路径上存在,即使它没有添加到项目依赖项中。我添加了这样的修正:

<plugin>
     <groupId>org.apache.maven.plugins</groupId>
     <artifactId>maven-surefire-plugin</artifactId>
     <version>${maven-surefire-plugin.version}</version>
     <configuration>
        <systemPropertyVariables>
            <org.springframework.boot.logging.LoggingSystem>
                org.springframework.boot.logging.log4j2.Log4J2LoggingSystem
            </org.springframework.boot.logging.LoggingSystem>
        </systemPropertyVariables>
    </configuration>
</plugin>

我的问题是:要么删除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'
    }
}
到我的gradle.build,并用最新版本刷新了所有项目依赖项,问题得到解决。

根据,捆绑和不可删除的Kotlin插件(提醒我将U2的相册强制包含在iOS中)包括
org.gradle.Kotlin.Kotlin dsl
,这反过来又用不兼容的日志库污染了类路径(即使已禁用)

我通过在首选项中将runner从“IntelliJ IDEA”更改为“Gradle”解决了这个问题:

  • 构建、执行、部署
    • 构建工具
      • 格拉德尔
        • 使用->Gradle构建跑步记录
        • 使用->Gradle运行测试

将尽我所能:在我的情况下,这是因为gradle插件部分中的“java gradle插件”也适用于webflux
compile(组:'org.springframework.boot',名称:'spring boot starter webflux',版本:'2.2.6.RELEASE'){//exclude modules}
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'
    }
}