2016-05-13 86 views
2

斯卡拉初學者在這裏,我在這裏嘗試的例子:斯卡拉曖昧進口

https://raw.githubusercontent.com/sryza/aas/master/ch02-intro/src/main/scala/com/cloudera/datascience/intro/RunIntro.scala

val nasRDD = parsed.map(md => { 
    md.scores.map(d => NAStatCounter(d)) 
}) 

上面給我的錯誤:

<console>:51: error: reference to NAStatCounter is ambiguous; 
it is imported twice in the same scope by 
import $VAL180.NAStatCounter 
and import INSTANCE.NAStatCounter 
      md.scores.map(d => NAStatCounter(d)) 
          ^

誰能請解釋爲什麼這雙進口正在發生。我該如何避免這種情況?

+1

你可以添加所有的進口嗎? – marios

回答

0

我無法重現您的問題。我把RunIntro.scala成一個小SBT項目,並與build.sbt文件(空行刪除)

% cat build.sbt 
name := "RunIntro" 
version := "1.0" 
scalaVersion := "2.11.8" 
libraryDependencies ++= List("org.apache.spark" % "spark-core_2.11" % "1.6.1") 

進口只是你的問題的根源的一部分,成功編譯它。你如何編譯這個源代碼?