FlinkSQL 数据写入kafka报错ThreadUtils

在使用FlinkSQL连接Kafka时遇到NoClassDefFoundError关于ThreadUtils的错误,原因是缺少Apache Kafka的相关依赖。解决方法是在pom文件中添加kafka的依赖,具体代码示例已给出。
摘要由CSDN通过智能技术生成

pom文件

flink-connector-debezium:2.2.0
flink-connector-kafka_2.11:1.13.6
flink-connector-mysql-cdc:2.20
flink-connector-kafka_2.11:1.13.6

报错

java.lang.NoClassDefFoundError: org/apache/kafka/common/utils/ThreadUtils at com.ververica.cdc.debezium.internal.FlinkOffsetBackingStore.start(FlinkOffsetBackingStore.java:152) ~[flink-connector-debezium-2.2.0.jar:2.2.0] at com.ververica.cdc.debezium.internal.FlinkOffsetBackingStore.configure(FlinkOffsetBackingStore.java:71) ~[flink-connector-debezium-2.2.0.jar:2.2.0] at io.debezium.embedded.EmbeddedEngine.run(EmbeddedEngine.java:690) [debezium-embedded-1.5.4.Final.jar:1.5.4.Final] at io.debezium.embedded.ConvertingEngineBuilderWorker.run(ThreadPoolExecutor.java:617) [?:1.8.0_121] at java.lang.Thread.run(Thread.java:745) [?:1.8.0_121] 19:49:50,611 ERROR com.ververica.cdc.debezium.internal.Handover [] - Reporting error: java.lang.NoClassDefFoundError: org/apache/kafka/common/utils/ThreadUtils at com.ververica.cdc.debezium.internal.FlinkOffsetBackingStore.start(FlinkOffsetBackingStore.java:152) ~[flink-connector-debezium-2.2.0.jar:2.2.0] at com.ververica.cdc.debezium.internal.FlinkOffsetBackingStore.configure(FlinkOffsetBackingStore.java:71) ~[flink-connector-debezium-2.2.0.jar:2.2.0] at io.debezium.embedded.EmbeddedEngine.run(EmbeddedEngine.java:690) [debezium-embedded-1.5.4.Final.jar:1.5.4.Final] at

解决方案

添加kafka依赖

<dependency>
    <groupId>org.apache.kafka</groupId>
    <artifactId>kafka-clients</artifactId>
    <version>2.7.0</version>
</dependency>

代码案例

import org.apache.flink.configuration.Configuration;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.table.api.EnvironmentSettings;
import org.apache.flink.table.api.bridge.java.StreamTableEnvironment;
public class Testkafka {
    public static void main(String[] args) throws Exception {
        Configuration conf = new Configuration();
        StreamExecutionEnvironment env = StreamExecutionEnviron
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值