当前位置: 首页 > 知识库问答 >
问题:

模块冲突。LoggerFactory不是LoggerContext,但Logback位于类路径上

祁博涛
2023-03-14

当我试图运行我的项目时,我得到了标题中发现的错误。我已经阅读了关于此错误的其他线程,并找到了一个解决方案,该解决方案消除了该错误,但杀死了我所有的日志记录。

<exclusions>
    <exclusion>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-logging</artifactId>
    </exclusion>
</exclusions>
<exclusions>
    <exclusion>
        <groupId>ch.qos.logback</groupId>
        <artifactId>logback-classic</artifactId>
    </exclusion>
</exclusions>

线程“main”java.lang.IllegalArgumentException中的异常:LoggerFactory不是LoggerContext,但Logback位于类路径上。删除Logback或竞争实现(类org.slf4j.impl.log4jLoggerFactory从文件:/c://users/me/.m2/repository/org/slf4j/slf4j-log4j12/1.6.4/slf4j-log4j12-1.6.4.jar加载)。如果您正在使用WebLogic,则需要将'org.slf4j'添加到WEB-INF/WebLogic.xml:org.slf4j.impl.log4jLoggerFactory中的preference-application-packages中

编辑:POM:

<dependencies>
    <dependency>
        <groupId>com.marklogic</groupId>
        <artifactId>mlcp</artifactId>
        <version>8.0-4</version>
    </dependency>
    <dependency>
        <groupId>org.apache.avro</groupId>
        <artifactId>avro</artifactId>
        <version>1.7.4</version>
    </dependency>
    <dependency>
        <groupId>commons-cli</groupId>
        <artifactId>commons-cli</artifactId>
        <version>1.2</version>
    </dependency>
    <dependency>
        <groupId>commons-codec</groupId>
        <artifactId>commons-codec</artifactId>
        <version>1.4</version>
    </dependency>
    <dependency>
        <groupId>commons-configuration</groupId>
        <artifactId>commons-configuration</artifactId>
        <version>1.6</version>
    </dependency>
    <dependency>
        <groupId>commons-lang</groupId>
        <artifactId>commons-lang</artifactId>
        <version>2.6</version>
    </dependency>
    <dependency>
        <groupId>commons-logging</groupId>
        <artifactId>commons-logging</artifactId>
        <version>1.1.3</version>
    </dependency>
    <dependency>
        <groupId>commons-modeler</groupId>
        <artifactId>commons-modeler</artifactId>
        <version>2.0.1</version>
    </dependency>
    <dependency>
        <groupId>com.google.guava</groupId>
        <artifactId>guava</artifactId>
        <version>11.0.2</version>
    </dependency>
    <dependency>
        <groupId>org.apache.hadoop</groupId>
        <artifactId>hadoop-annotations</artifactId>
        <version>2.6.0</version>
    </dependency>
    <dependency>
        <groupId>org.apache.hadoop</groupId>
        <artifactId>hadoop-auth</artifactId>
        <version>2.6.0</version>
    </dependency>
    <dependency>
        <groupId>org.apache.hadoop</groupId>
        <artifactId>hadoop-common</artifactId>
        <version>2.6.0</version>
    </dependency>
    <dependency>
        <groupId>org.apache.hadoop</groupId>
        <artifactId>hadoop-hdfs</artifactId>
        <version>2.6.0</version>
    </dependency>
    <dependency>
        <groupId>org.apache.hadoop</groupId>
        <artifactId>hadoop-mapreduce-client-common</artifactId>
        <version>2.6.0</version>
    </dependency>
    <dependency>
        <groupId>org.apache.hadoop</groupId>
        <artifactId>hadoop-mapreduce-client-core</artifactId>
        <version>2.6.0</version>
    </dependency>
    <dependency>
        <groupId>org.apache.hadoop</groupId>
        <artifactId>hadoop-mapreduce-client-jobclient</artifactId>
        <version>2.6.0</version>
    </dependency>
    <dependency>
        <groupId>org.apache.hadoop</groupId>
        <artifactId>hadoop-yarn-api</artifactId>
        <version>2.6.0</version>
    </dependency>
    <dependency>
        <groupId>org.apache.hadoop</groupId>
        <artifactId>hadoop-yarn-common</artifactId>
        <version>2.6.0</version>
    </dependency>
    <dependency>
        <groupId>org.codehaus.jackson</groupId>
        <artifactId>jackson-jaxrs</artifactId>
        <version>1.8.3</version>
    </dependency>
    <dependency>
        <groupId>org.codehaus.jackson</groupId>
        <artifactId>jackson-xc</artifactId>
        <version>1.8.3</version>
    </dependency>
    <dependency>
        <groupId>org.codehaus.jackson</groupId>
        <artifactId>jackson-core-asl</artifactId>
        <version>1.9.13</version>
    </dependency>
    <dependency>
        <groupId>org.codehaus.jackson</groupId>
        <artifactId>jackson-mapper-asl</artifactId>
        <version>1.9.13</version>
    </dependency>
    <dependency>
        <groupId>log4j</groupId>
        <artifactId>log4j</artifactId>
        <version>1.2.17</version>
    </dependency>
    <dependency>
        <groupId>com.google.protobuf</groupId>
        <artifactId>protobuf-java</artifactId>
        <version>2.5.0</version>
    </dependency>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-api</artifactId>
        <version>1.6.1</version>
    </dependency>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-log4j12</artifactId>
        <version>1.6.4</version>
    </dependency>
    <dependency>
        <groupId>xerces</groupId>
        <artifactId>xercesImpl</artifactId>
        <version>2.10.0</version>
    </dependency>
    <dependency>
        <groupId>xpp3</groupId>
        <artifactId>xpp3</artifactId>
        <version>1.1.3.3</version>
    </dependency>
    <dependency>
        <groupId>org.apache.jena</groupId>
        <artifactId>jena-arq</artifactId>
        <version>2.10.0</version>
    </dependency>
    <dependency>
        <groupId>org.apache.jena</groupId>
        <artifactId>jena-core</artifactId>
        <version>2.10.0</version>
    </dependency>
    <dependency>
        <groupId>org.apache.jena</groupId>
        <artifactId>jena-iri</artifactId>
        <version>0.9.5</version>
    </dependency>
    <dependency>
        <groupId>org.apache.solr</groupId>
        <artifactId>solr-commons-csv</artifactId>
        <version>3.5.0</version>
    </dependency>
    <dependency>
        <groupId>xml-apis</groupId>
        <artifactId>xml-apis</artifactId>
        <version>1.4.01</version>
    </dependency>
    <dependency>
        <groupId>com.thoughtworks.xstream</groupId>
        <artifactId>xstream</artifactId>
        <version>1.4.2</version>
    </dependency>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.11</version>
    </dependency>
    <dependency>
        <groupId>commons-collections</groupId>
        <artifactId>commons-collections</artifactId>
        <version>3.2.1</version>
    </dependency>
    <dependency>
        <groupId>org.apache.hadoop</groupId>
        <artifactId>hadoop-yarn-client</artifactId>
        <version>2.6.0</version>
    </dependency>
    <dependency>
        <groupId>com.sun.jersey</groupId>
        <artifactId>jersey-client</artifactId>
        <version>1.9</version>
    </dependency>
    <dependency>
        <groupId>com.sun.jersey</groupId>
        <artifactId>jersey-core</artifactId>
        <version>1.9</version>
    </dependency>
    <dependency>
        <groupId>org.htrace</groupId>
        <artifactId>htrace-core</artifactId>
        <version>3.0.4</version>
    </dependency>
    <dependency>
        <groupId>com.marklogic</groupId>
        <artifactId>marklogic-xcc</artifactId>
        <version>8.0.4</version>
    </dependency>
    <dependency>
        <groupId>com.marklogic</groupId>
        <artifactId>marklogic-mapreduce2</artifactId>
        <version>2.1.4</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>
</dependencies>

共有1个答案

卫沈义
2023-03-14

我在wildfly 23中部署Spring boot时遇到了同样的问题

因此,我通过按以下顺序添加依赖项来解决这个问题。

 <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-log4j2</artifactId>
    </dependency>

 <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-starter-tomcat</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-starter-logging</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
 类似资料:
  • 我认为spring-boot-starter-security中的某个模块与log4j冲突,但我不知道是哪一个。 我的gradle依赖性如下:

  • 我到处都使用gradle和,但是,最近我的Spring Boot应用程序停止了从命令行运行。当我运行时,我得到... 线程“main”java.lang.IllegalArgumentException中的异常:LoggerFactory不是LoggerContext,但Logback位于类路径上。删除Logback或竞争实现(类org.slf4j.impl.log4jLoggerFactory从

  • 我正在为我的应用程序部署一个spring boot可执行jar。我使用SLF4J日志记录,当我在IntelliJ内部构建和运行时,我没有任何问题。 然而,当我尝试运行.jar时,从命令行我得到一个LoggerFactory不是Logback LoggerContext,而是Logback在类路径异常上。 它在两个地方抱怨slf4j-log4j12-1.7.12.jar。 如果我从这两个位置移除ja

  • 我正尝试使用hadoop 2.7.2和AllXIO从AWS上的spark 2.1.0独立集群连接到redshift,这给我带来了以下错误:

  • 我怎样才能解决这个问题。我不能使这个数据绑定工作,我已经尝试了一切。build.gradle(模块应用程序) 我尝试添加kapt“com.android.dataBinding:compiler:$compiler_version”,但它给了我一个错误。Build.Gradle(模块项目) 行binding.user=user给了我一个错误:不能访问类'usermodel.user'。检查您的模块

  • (网页包)/buildin/global。js有多个模块,它们的名称只是大小写不同。在具有其他case语义的文件系统上编译时,这可能会导致意外行为。使用相等的外壳。比较这些模块标识符: C:\Users\user\Desktop\projects\LINK\LinkparmacySystem\node\u modules\react scripts\node\u modules\babel loa