Apache spark 为什么从sbt会话内编译Spark应用程序失败,并出现“错误”;对象apache不是包org的成员;?
我创建了一个简单的文件Apache spark 为什么从sbt会话内编译Spark应用程序失败,并出现“错误”;对象apache不是包org的成员;?,apache-spark,sbt,Apache Spark,Sbt,我创建了一个简单的文件hello.scala,其中包含以下代码: import org.apache.spark.SparkContext object HelloSbt extends App { println("Welcome to this thing!") } 请注意,我没有使用IDE 当我运行命令compile时,出现以下错误: 对象apache不是包org的成员 没有导入行的代码可以正常工作 我在网上查了一下,他们说我应该修改build.sbt并在其中添加一些行构建.sbt
hello.scala
,其中包含以下代码:
import org.apache.spark.SparkContext
object HelloSbt extends App {
println("Welcome to this thing!")
}
请注意,我没有使用IDE
当我运行命令compile
时,出现以下错误:
对象apache不是包org的成员
没有导入行的代码可以正常工作
我在网上查了一下,他们说我应该修改build.sbt
并在其中添加一些行<代码>构建.sbt如下所示:
name := "tasky"
version := "0.1.0"
scalaVersion := "2.12.3"
libraryDependencies ++= Seq(
"org.apache.spark" %% "spark-core" % "0.9.0-incubating",
"org.apache.spark" %% "spark-streaming" % "0.9.0-incubating",
"org.apache.spark" %% "spark-streaming-twitter" % "0.9.0-incubating")
compile
仍然会失败,并出现错误。为什么?启动sbt并在sbt shell中后,shell将不会拾取对build.sbt
所做的任何更改,直到您执行重新加载
(这将重新加载自会话启动以来所做的任何更改)
您的
build.sbt有两个问题
您应该使用最新和最好的2.2.0
作为Spark dependencies的版本
Spark支持Scala 2.11,因此scalaVersion
应该是2.11.8
(最高达2.11.11
)
sbt:so> help reload
reload
(Re)loads the project in the current directory.
reload plugins
(Re)loads the plugins project (under project directory).
reload return
(Re)loads the root project (and leaves the plugins project).