';' expected but 'import' found - Scala and Spark

时光毁灭记忆、已成空白 提交于 2019-12-10 19:28:30

问题


I'm trying to work with Spark and Scala, compiling a standalone application. I don't know why I'm getting this error:

topicModel.scala:2: ';' expected but 'import' found.
[error] import org.apache.spark.mllib.clustering.LDA
[error] ^
[error] one error found
[error] (compile:compileIncremental) Compilation failed

This is the build.sbt code:

name := "topicModel"

version := "1.0"

scalaVersion := "2.11.6"

libraryDependencies += "org.apache.spark" %% "spark-core" % "1.3.1"
libraryDependencies += "org.apache.spark" %% "spark-graphx" % "1.3.1"
libraryDependencies += "org.apache.spark" %% "spark-mllib" % "1.3.1"

And those are the imports:

import scala.collection.mutable
import org.apache.spark.mllib.clustering.LDA
import org.apache.spark.mllib.linalg.{Vector, Vectors}
import org.apache.spark.rdd.RDD

object Simple {
  def main(args: Array[String]) {

回答1:


This could be because your file has old Macintosh line endings (\r)?

See Why do I need semicolons after these imports? for more details.



来源:https://stackoverflow.com/questions/30422750/expected-but-import-found-scala-and-spark

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!