当我尝试创建一个kafka流实例时,会出现以下异常Exception in thread "main" java.lang.NoSuchMethodError: org.apache.kafka.common.metrics.Sensor.add(Lorg/apache/kafka/common/MetricName;Lorg/apache/kafka/common/metrics/MeasurableStat;)Z
at org.apache.kafka.streams.processor.internals.metrics.StreamsMetricsImpl.<init>(StreamsMetricsImpl.java:64)
at org.apache.kafka.streams.processor.internals.StreamThread$StreamsMetricsThreadImpl.<init>(StreamThread.java:525)
at org.apache.kafka.streams.processor.internals.StreamThread.create(StreamThread.java:618)
at org.apache.kafka.streams.KafkaStreams.<init>(KafkaStreams.java:706)
at org.apache.kafka.streams.KafkaStreams.<init>(KafkaStreams.java:624)
at org.apache.kafka.streams.KafkaStreams.<init>(KafkaStreams.java:534)
我试图在intellij中运行WordCountDemo scala示例,但无法执行。我的项目中包含了org.apache.kafka:kafka-streams-scala_2.11:2.1.0
和org.apache.kafka:kafka-clients:1.0.2
依赖项,并看到导入的jar。
@Matthias 已经在评论中找到了答案
您将需要与KafkaStreams版本匹配的相同客户端版本org.apache.kafka:kafka-clients:2.1.0
这已被确认适用于询问者。