1. 程式人生 > >求助:scala的json4s把JValue轉為物件時報錯 java.lang.NoSuchMethodError: scala.Predef$.$conforms()Lscala/Predef$$less$colon$less;

求助:scala的json4s把JValue轉為物件時報錯 java.lang.NoSuchMethodError: scala.Predef$.$conforms()Lscala/Predef$$less$colon$less;

測試程式碼:
import org.json4s._

import org.json4s.JsonDSL._
import org.json4s.jackson.JsonMethods._
case class Winner(id: Long, numbers: List[Int])
object Test extends App{
val winner = Winner(23, List(2, 45, 34, 23, 3, 5))
  //Winner轉json
val json = ("id" -> winner.id) ~ ("numbers" -> winner.numbers)

//json轉String
val str: String = compact(render(json))
println(str)
implicit val formats = DefaultFormats
//String轉json
val jValue: JValue = parse(str)
//json轉Winner
val winner2: Winner = jValue.extract[Winner]
print(winner2)
}
報錯:Exception in thread "main" java.lang.NoSuchMethodError: scala.Predef$.$conforms()Lscala/Predef$$less$colon$less;

spark是1.6.1,scala是2.10.5

porm.xml
<dependency>
    <groupId>org.apache.spark</groupId>
<artifactId>spark-core_2.10</artifactId>
<version>1.6.1</version>
</dependency>
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-streaming_2.10</artifactId>

<version>1.6.1</version>
</dependency>
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-streaming-kafka_2.10</artifactId>
<version>1.6.1</version>
</dependency>
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-library</artifactId>
<version>2.10.5</version>
</dependency>
<dependency>
    <groupId>org.json4s</groupId>
<artifactId>json4s-jackson_2.10</artifactId>
<version>3.5.3</version>
</dependency>
<dependency>
<groupId>org.apache.kafka</groupId>
<artifactId>kafka_2.10</artifactId>
<version>0.8.2.1</version>
</dependency>
為什麼一直報錯,救助!?