码迷,mamicode.com
首页 > 编程语言 > 详细

求助:scala的json4s把JValue转为对象时报错 java.lang.NoSuchMethodError: scala.Predef$.$conforms()Lscala/Predef$$less$colon$less;

时间:2018-11-27 13:05:10      阅读:1091      评论:0      收藏:0      [点我收藏+]

标签:list   col   streaming   jackson   mat   cas   port   apache   library   

测试代码:
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>
为什么一直报错,救助!?
 

求助:scala的json4s把JValue转为对象时报错 java.lang.NoSuchMethodError: scala.Predef$.$conforms()Lscala/Predef$$less$colon$less;

标签:list   col   streaming   jackson   mat   cas   port   apache   library   

原文地址:https://www.cnblogs.com/dummyly/p/10025733.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!