测试代码: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.5porm.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>为什么一直报错,救助!?
原文地址:https://www.cnblogs.com/dummyly/p/10025733.html
时间: 2024-10-07 16:21:36