请稍等 ...
×

采纳答案成功!

向帮助你的同学说点啥吧!感谢那些助人为乐的人

Flink CDC 编程遇到的问题

package com.imooc.flink.cdc

import com.ververica.cdc.connectors.mysql.MySqlSource
import com.ververica.cdc.connectors.mysql.table.StartupOptions
import com.ververica.cdc.debezium.{DebeziumSourceFunction, StringDebeziumDeserializationSchema}
import org.apache.flink.api.scala._
import org.apache.flink.streaming.api.scala.StreamExecutionEnvironment

object FlinkCDCDataStreamApp {
  def main(args: Array[String]): Unit = {
    val environment = StreamExecutionEnvironment.getExecutionEnvironment
    environment.setParallelism(1)

    val source: DebeziumSourceFunction[String] = MySqlSource.builder()
      .hostname("localhost").port(3306)
      .username("root").password("1997")
      .databaseList("pk_cdc").tableList("user")
      .startupOptions(StartupOptions.initial())
      //设置反序列化
      .deserializer(new StringDebeziumDeserializationSchema)
      .build()

    environment.addSource(source).print()

    environment.execute("FlinkCDCDataStreamApp");
  }

}


错误:


Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/flink/shaded/guava18/com/google/common/collect/Maps
	at com.ververica.cdc.connectors.mysql.MySqlValidator.<init>(MySqlValidator.java:50)
	at com.ververica.cdc.connectors.mysql.MySqlSource$Builder.build(MySqlSource.java:230)
	at com.imooc.flink.cdc.FlinkCDCDataStreamApp$.main(FlinkCDCDataStreamApp.scala:20)
	at com.imooc.flink.cdc.FlinkCDCDataStreamApp.main(FlinkCDCDataStreamApp.scala)
Caused by: java.lang.ClassNotFoundException: org.apache.flink.shaded.guava18.com.google.common.collect.Maps
	at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:355)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
	... 4 more

Process finished with exit code 1

Scala用了2.11和2.12的都试了

正在回答 回答被采纳积分+3

1回答

Michael_PK 2022-04-10 15:41:07

遇到类似的ClassNotFoundException问题:ClassNotFoundException: org.apache.flink.shaded.guava18.com.google.common.collect.Map


按照如下思路解决:找到这个类所在的jar包,添加到pom中



你使用的flink版本和cdc的版本是否和上课的不一致? 


0 回复 有任何疑惑可以回复我~

相似问题

登录后可查看更多问答,登录/注册

问题已解决,确定采纳
还有疑问,暂不采纳
意见反馈 帮助中心 APP下载
官方微信