2016-08-23 6 views
1

나는 스파크 스트리밍 + 카프카의 예가있다. 그것은 IDE에서 잘 작동합니다. 하지만 콘솔에서 SBT로 컴파일하려고하면 sbt가과 같이 컴파일됩니다. 오류가 있습니다.스파크 스트리밍 + 카프카 바이트 편집

메인 클래스 :

val conf = new SparkConf().setMaster("local[*]").setAppName("KafkaReceiver") 
    val ssc = new StreamingContext(conf, Seconds(5)) 

    val kafkaStream1 = KafkaUtils.createStream(ssc, "localhost:2181", "spark-streaming-consumer-group", Map("t1" -> 5)) 
    //val kafkaStream2 = KafkaUtils.createStream(ssc, "localhost:2181", "spark-streaming-consumer-group", Map("topic2" -> 5)) 

    //kafkaStream.fla 
    kafkaStream1.print() 
    ssc.start() 
    ssc.awaitTermination() 

오류 메시지 :

[error] bad symbolic reference. A signature in package.class refers to type compileTimeOnly 
[error] in package scala.annotation which is not available. 
[error] It may be completely missing from the current classpath, or the version on 
[error] the classpath might be incompatible with the version used when compiling package.class. 
Reference to method any2ArrowAssoc in object Predef should not have survived past type checking, 
[error] it should have been processed and eliminated during expansion of an enclosing macro. 
[error] val kafkaStream1 = KafkaUtils.createStream(ssc, "localhost:2181", "spark-streaming-consumer-group", Map("t1" -> 5)) 
[error]                           ^
[error] two errors found 
[error] (compile:compileIncremental) Compilation failed 

SBT :

name := "test" 
    val sparkVersion = "2.0.0" 

    lazy val commonSettings = Seq(
     organization := "com.test", 
     version := "1.0", 
     scalaVersion := "2.11.8", 
     test in assembly := {} 
    )  
libraryDependencies ++= Seq(
    "org.apache.spark" % "spark-streaming_2.11" % sparkVersion, 
    "org.apache.spark" % "spark-streaming-kafka-0-8_2.11" % sparkVersion 
) 

당신이 어떻게 문제를 해결하는 아이디어가 있습니까?

+0

이것은 몇 가지 단서를 제공합니다. http : //stackoverflow.com/questions/24472645/why-does-sbt-say-bad-symbolic-reference-for-test-with-scalatest – kosa

답변

0

build.sbt를 공유 할 수 있습니까? "잘못된 기호 참조"문제를 일으킬 수있는 이유 중 하나는 스칼라 버전 불일치입니다. 그 문제에 대한 자세한 내용은 topic을보십시오. 스칼라 버전이 spark에서 기대하는 것과 똑같은지 확인하십시오. 자세한 내용은 this blog post을 참조하십시오.

+0

scala 2.10을 사용해야합니까? – scala

+0

그것은 Spark의 버전에 따라 다릅니다. 예를 들어 Spark 1.3.1은 Scala 2.10.4를 사용하지만 Spark 2.0은 Scala 2.11을 사용합니다. *, –

+0

을 사용하여 Spark 버전의 설명서를보십시오. 정말 이상합니다. 나는 spark 2.0.0과 scala 2.11.8을 사용한다. 업데이트 된 build.sbt는이 설명서 (http://spark.apache.org/docs/latest/streaming-kafka-integration.html)를 사용했습니다. IDE에서 작동하지만 명령 줄 "sbt compile"에서 같은 오류가 발생합니다 ... – scala

관련 문제