gpt4 book ai didi

scala - 找到“;' expected but ' 导入”-Scala 和 Spark

转载 作者:行者123 更新时间:2023-12-02 04:49:09 24 4
gpt4 key购买 nike

我正在尝试使用 Spark 和 Scala,编译一个独立的应用程序。我不知道为什么会收到此错误:

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

这是 build.sbt 代码:

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"

那些是进口的:

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]) {

最佳答案

这可能是因为您的文件有旧的 Macintosh 行结尾 (\r)?

参见 Why do I need semicolons after these imports?了解更多详情。

关于scala - 找到“;' expected but ' 导入”-Scala 和 Spark,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30422750/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com