0

我已经添加了

"org.apache.bahir" %% "spark-streaming-mqtt" % "2.4.0"

到我的build.sbt,并使用

df
  .writeStream
  .format("org.apache.bahir.sql.streaming.mqtt.MQTTStreamSinkProvider")
  .outputMode("complete")
  .option("topic", "mytopic")
  .option("brokerUrl", "tcp://localhost:1883")
  .start()
  .awaitTermination(20000)

在代码中,但得到

java.lang.ClassNotFoundException: Failed to find data source: org.apache.bahir.sql.streaming.mqtt.MQTTStreamSinkProvider. Please find packages at http://spark.apache.org/third-party-projects.html

    at org.apache.spark.sql.execution.datasources.DataSource$.lookupDataSource(DataSource.scala:679)
4

1 回答 1

0

我已经意识到这种行为的原因是使用了错误的依赖"org.apache.bahir" %% "spark-streaming-mqtt" % "2.4.0"而不是"org.apache.bahir" %% "spark-sql-streaming-mqtt" % "2.4.0"

修复后我遇到了新问题

于 2021-10-13T12:45:36.227 回答