【问题标题】:Spark dependencies configuration for streaming from Twitter从 Twitter 流式传输的 Spark 依赖项配置
【发布时间】:2018-04-08 21:29:52
【问题描述】:

我正在尝试使用 Twitter 流运行 Spark 应用程序。但是,我经常遇到依赖问题。 当我使用 org.apache.bahir spark-streaming-twitter 依赖项时,出现这样的错误:

module not found: org.apache.bahir#spark-streaming-twitter;2.0.0

这里是对应的build.sbt文件:

version := "0.1"
scalaVersion := "2.11.12"

libraryDependencies ++= Seq(
    "org.apache.bahir" %% "spark-streaming-twitter" % "2.0.0",
  "org.apache.spark" %% "spark-core" % "2.3.0",
  "org.apache.spark" % "spark-streaming_2.11" % "2.3.0",
  "com.typesafe" % "config" % "1.3.0",
  "org.twitter4j" % "twitter4j-stream" % "4.0.6"
)

但是当我使用旧的流依赖时,我得到ClassNotFoundException: : org.apache.spark.Logging 错误。 下面是对应的build.sbt:

version := "0.1"
scalaVersion := "2.11.12"

libraryDependencies ++= Seq(
  "org.apache.spark" %% "spark-core" % "2.3.0",
  "org.apache.spark" % "spark-streaming_2.11" % "2.3.0",
  "com.typesafe" % "config" % "1.3.0",
  "org.twitter4j" % "twitter4j-stream" % "4.0.6",
  "org.apache.spark" %% "spark-streaming-twitter" % "1.6.3"
)

为了运行我的应用程序,我运行sbt clean and package 命令。 那么我应该使用哪些依赖项以及如何配置它们来运行我的应用程序?

【问题讨论】:

    标签: scala apache-spark twitter sbt


    【解决方案1】:

    Twitter 后端已从 Spark 2.0 版本中删除,并且您声明的 bahir 版本与 Spark 版本不匹配。最后,bahir Twitter 已经带有 twitter4j-stream 依赖项(此时为 4.0.4)。使用:

    val sparkVersion = "2.3.0"
    
    libraryDependencies ++= Seq(
      "org.apache.bahir" %% "spark-streaming-twitter" % sparkVersion,
      "org.apache.spark" %% "spark-core" % sparkVersion,
      "org.apache.spark" %% "spark-streaming" % sparkVersion
    )
    

    【讨论】:

    • 如果您不想自己为 2.3 构建 Bahir,则必须将 所有 依赖项降级到 2.2。您不能在主要版本之间混用。
    • 看起来您没有使用正确的构建定义。消息显示您的尝试不包括 Scala 版本。 %%% 之间有区别(你需要 org.apache.spark#spark-launcher_2.11;2.2.0 而不是 org.apache.bahir#spark-streaming-twitter;2.2.0
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-06-12
    • 2015-04-25
    • 2018-05-27
    • 2023-02-16
    • 2015-04-12
    • 2020-07-17
    • 1970-01-01
    相关资源
    最近更新 更多