flink消费kafka报错:org.apache.kafka.clients.consumer.KafkaConsumer.assign(Ljava/util/List;)V

flink消费kafka上数据时报错:
Caused by: java.lang.NoSuchMethodError: org.apache.kafka.clients.consumer.KafkaConsumer.assign(Ljava/util/List;)V

错误原因:
Flink的kafka Consumer版本和kafka-client的版本不一致
flink消费kafka报错:org.apache.kafka.clients.consumer.KafkaConsumer.assign(Ljava/util/List;)V_第1张图片
flink消费kafka报错:org.apache.kafka.clients.consumer.KafkaConsumer.assign(Ljava/util/List;)V_第2张图片
在这里插入图片描述
解决方案:三者版本一致

正确配置

pom:
       
            org.apache.flink
            flink-connector-kafka-0.10_2.11
            ${flink.version}
        
 
        
            org.apache.kafka
            kafka-clients
            ${kafka.version}
        
 
code:
val kafka09 =new  FlinkKafkaConsumer09[String](topics,new SimpleStringSchema(),properties)
//对应的kafka.version=0.9.0.1
 
val kafka010=new  FlinkKafkaConsumer010[String](topics,new SimpleStringSchema(),properties)
//对应的kakfa.version=1.0.0

参考:https://blog.csdn.net/wangyu1025391259/article/details/86627954

你可能感兴趣的:(Flink,kafka)