0

我正在尝试将数据从 Mongo 添加到 Kafka 主题。但是我在启动后发现了这样的异常:

Caused by: java.lang.NoClassDefFoundError: Could not initialize class com.mongodb.kafka.connect.source.MongoSourceConfig
    at com.mongodb.kafka.connect.MongoSourceConnector.config(MongoSourceConnector.java:91)
    at org.apache.kafka.connect.runtime.AbstractHerder.validateConnectorConfig(AbstractHerder.java:366)
    at org.apache.kafka.connect.runtime.AbstractHerder.lambda$validateConnectorConfig$1(AbstractHerder.java:326)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    ... 1 more

检查可用的连接器列表后,我看到了这个类

class":"com.mongodb.kafka.connect.MongoSourceConnector","type":"source","version":"1.5.0"},

我的错误在哪里?谢谢!我的连接配置:

curl -X POST -H "Content-Type: application/json" --data '
  {"name": "mongo-source-stockdata",
   "config": {
     "tasks.max":"1",
     "connector.class":"com.mongodb.kafka.connect.MongoSourceConnector",
     "key.converter":"org.apache.kafka.connect.json.JsonConverter",
     "value.converter":"org.apache.kafka.connect.json.JsonConverter",
      "connection.uri":"mongodb://localhost:27017",
     "topic.prefix":"t_cb_",
     "database":"testdb",
     "collection":"contactbook_test"
}}' http://localhost:8083/connectors -w "\n"
4

0 回答 0