2016-05-13 12 views
2

Scala Anfänger hier und ich habe versucht, das Beispiel hier aus:Scala mehrdeutig Importe

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)) 
}) 

Der Fehler gibt mir oben:

<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)) 
          ^

Kann jemand bitte erklären, warum diese Doppel Import passiert. Wie kann ich das abwenden?

+1

können Sie all Ihre Importe hinzufügen? – marios

Antwort

0

Ich konnte Ihr Problem nicht reproduzieren. Ich habe RunIntro.scala in ein kleines sbt Projekt und es erfolgreich mit dem build.sbt Datei kompiliert (mit Leerzeilen entfernt)

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

Die Importe sind nur ein Teil der Ursache des Problems. Wie kompilierst du diese Quelle?