cari

Rumah  >  Soal Jawab  >  teks badan

java - log4j、log4j2冲突问题

迷茫迷茫2806 hari yang lalu823

membalas semua(3)saya akan balas

  • PHP中文网

    PHP中文网2017-04-18 10:40:47

      Versi selepas
    1. zookeeper-3.4.0 telah menggunakan antara muka log slf4j dan anda boleh terus mengecualikan kebergantungan berkaitan log4j.

    2. Jika zookeeper ialah versi sebelum 3.4.0 dan perlu ditingkatkan kepada zookeeper, ulang langkah 1

    penjaga zoo-3.4.0


    kafka_2.9.1-0.8.2.2

    <dependency>
        <groupId>com.101tec</groupId>
        <artifactId>zkclient</artifactId>
        <version>0.3</version>
        <scope>compile</scope>
    </dependency>

    Saya baru sahaja menyemak bahawa versi kafka yang digunakan dalam zkclient agak rendah Dalam versi yang lebih tinggi, zkclient juga telah bertukar kepada antara muka slf4j Anda boleh meningkatkan zkclient.

    balas
    0
  • PHP中文网

    PHP中文网2017-04-18 10:40:47

    <dependency>
          <groupId>org.apache.kafka</groupId>
          <artifactId>kafka_2.9.1</artifactId>
          <version>0.8.2.2</version>
          <exclusions>
              <exclusion>
                   <artifactId>log4j</artifactId>
                   <groupId>log4j</groupId>
              </exclusion>
         </exclusions>
    </dependency>

    Selepas melakukan pengecualian, ralat berlaku:

    java.lang.NoClassDefFoundError: org/apache/log4j/Logger
    
        at org.I0Itec.zkclient.ZkClient.<clinit>(ZkClient.java:57)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at org.junit.runners.model.FrameworkMethod.runReflectiveCall(FrameworkMethod.java:50)
        at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
        at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
        at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
        at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
        at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
        at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
        at org.junit.runners.ParentRunner.run(ParentRunner.java:290)
        at org.junit.runners.ParentRunner.schedule(ParentRunner.java:71)
        at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
        at org.junit.runners.ParentRunner.accessrrreee0(ParentRunner.java:58)
        at org.junit.runners.ParentRunner.evaluate(ParentRunner.java:268)
        at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
        at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
        at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:119)
        at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:42)
        at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:234)
        at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:74)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)
    Caused by: java.lang.ClassNotFoundException: org.apache.log4j.Logger
        at java.net.URLClassLoader.run(URLClassLoader.java:366)
        at java.net.URLClassLoader.run(URLClassLoader.java:355)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
        ... 30 more

    penjaga zoo versi 3.4.6

    balas
    0
  • 巴扎黑

    巴扎黑2017-04-18 10:40:47

    Selepas mengecualikan log4j, tambahkan log4j-1.2-api ini

    balas
    0
  • Batalbalas