我在ubuntu home path中编写了一个scala脚本.scala,并对twitter应用程序中的所有oauth值进行了硬编码:
import org.apache.spark.streaming.{Seconds, StreamingContext}
import org.apache.spark.SparkContext._
import org.apache.spark.streaming.twitter._
import org.apache.spark.SparkConf
System.setProperty("twitter4j.oauth.consumerKey", consumerKey)
System.setProperty("twitter4j.oauth.consumerSecret", consumerSecret)
System.setProperty("twitter4j.oauth.accessToken", accessToken)
System.setProperty("twitter4j.oauth.accessTokenSecret", accessTokenSecret)
val filters="Raj"
val sparkConf = new SparkConf().setAppName("TwitterPopularTags").setMaster("local[2]")
val ssc = new StreamingContext(sparkConf, Seconds(2))
val stream = TwitterUtils.createStream(ssc, None, filters)
我执行的是
$Spark_bin-2.7> cat abc.scala | ./spark-shell
它一直持续到streamingcontext。但当它到达twitterutils时,它会给出错误的读数:
错误:未找到:twitterutils
我下载了最新的spark 2.0.1。你能一步一步地指出设置或文件吗?
1条答案
按热度按时间kg7wmglp1#
添加org.apache。spark:spark-streaming-twitter_2.11:1.6.1Spark壳状
使用此方法