我正在尝试在Spark Shell中使用twitterUtils(默认情况下它们不可用).
我添加了以下内容spark-env.sh:
SPARK_CLASSPATH="/disk.b/spark-master-2014-07-28/external/twitter/target/spark-streaming-twitter_2.10-1.1.0-SNAPSHOT.jar"
Run Code Online (Sandbox Code Playgroud)
我现在可以执行了
import org.apache.spark.streaming.twitter._
import org.apache.spark.streaming.StreamingContext._
Run Code Online (Sandbox Code Playgroud)
没有shell中的错误,如果没有将jar添加到类路径中是不可能的("错误:对象twitter不是包org.apache.spark.streaming的成员").但是,在Spark shell中执行它时会出错:
scala> val ssc = new StreamingContext(sc, Seconds(1))
ssc: org.apache.spark.streaming.StreamingContext =
org.apache.spark.streaming.StreamingContext@6e78177b
scala> val tweets = TwitterUtils.createStream(ssc, "twitter.txt")
error: bad symbolic reference. A signature in TwitterUtils.class refers to
term twitter4j in package <root> which is not available.
It may be completely missing from the current classpath, or the version on the classpath might be incompatible with the version used when compiling
TwitterUtils.class.
Run Code Online (Sandbox Code Playgroud)
我错过了什么?我必须再导入另一个罐子吗?
apache-spark ×1