我在Apache的SLF4J日志中遇到了问题。我想在Apache中使用。我的Java应用程序必须集成到Camunda的BPM过程中。到目前为止,Java编码的集成也是有效的--没有Apache生产者的集成。如果将其集成到Camunda过程中,则会得到以下错误:
java.lang.LinkageError: loader constraint violation: when resolving method "org.slf4j.impl.StaticLoggerBinder.getLoggerFactory()Lorg/slf4j/ILoggerFactory;" the class loader (instance of org/apache/catalina/loader/ParallelWebappClassLoader) of the current class, org/slf4j/LoggerFactory, and the class loader (instance of java/net/URLClassLoader) for the method's defining class, org/slf4j/impl/StaticLoggerBinder, have different Class objects for the type org/slf4j/ILoggerFactory used in the signature
at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:418)
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:357)
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:383)
at org.apache.kafka.clients.CommonClientConfigs.<clinit>(CommonClientConfigs.java:32)
at org.apache.kafka.clients.producer.ProducerConfig.<clinit>(ProducerConfig.java:305)
at org.apache.kafka.clients.producer.KafkaProducer.<init>(KafkaProducer.java:304)据我所知,Camunda和Apache正在尝试调用SLF4J记录器,不是吗?但就我而言我需要卡蒙达记录器。所以我想禁用Apache日志来解决这个问题。到目前为止,我简单的卡夫卡制作人看起来是这样的:
String topicName = "camunda";
String test = "test123";
Properties props = new Properties();
props.put("bootstrap.servers", "localhost:9092,localhost:9093");
props.put("key.serializer","org.apache.kafka.common.serialization.StringSerializer");
props.put("value.serializer", "org.apache.kafka.common.serialization.StringSerializer");
Producer<String, String> producer = new KafkaProducer <>(props);
ProducerRecord<String, String> record = new ProducerRecord<>(topicName,test);
producer.send(record);
producer.close();有办法解决这个问题吗?不幸的是,我没有找到任何关于如何禁用Kafka Logger的条目,或者是其他地方的问题吗?
事先非常感谢
发布于 2018-10-19 15:45:50
禁用apache上的Maven依赖项SFL4J-Logger的方法对我来说很好。我将pom文件更改如下:
<dependency>
<groupId>org.apache.kafka</groupId>
<artifactId>kafka-clients</artifactId>
<version>2.0.0</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</exclusion>
</exclusions>
</dependency>https://stackoverflow.com/questions/52880915
复制相似问题