Получение NoSuchMethodError при попытке создания строк JSON из карты Scala с использованием Lift-JSON.
Пытался выполнить следующую программу из scala cookbook
package com.sample
import net.liftweb.json.JsonAST
import net.liftweb.json.JsonDSL._
import net.liftweb.json.Printer.{compact,pretty}
object LiftJsonWithCollections extends App {
val json = List(1, 2, 3)
println(compact(JsonAST.render(json)))
val map = Map("fname" -> "Alvin", "lname" -> "Alexander")
println(compact(JsonAST.render(map)))
}
Следующая ошибка, которую я получаю
Exception in thread "main" java.lang.NoSuchMethodError: scala.collection.immutable.$colon$colon.hd$1()Ljava/lang/Object;
at net.liftweb.json.Printer$class.layout$1(JsonAST.scala:597)
at net.liftweb.json.Printer$class.compact(JsonAST.scala:605)
at net.liftweb.json.Printer$.compact(JsonAST.scala:583)
at net.liftweb.json.Printer$class.compact(JsonAST.scala:590)
at net.liftweb.json.Printer$.compact(JsonAST.scala:583)
at com.sample.LiftJsonWithCollections$.delayedEndpoint$com$sample$LiftJsonWithCollections$1(LiftJsonWIthCollection.scala:10)
at com.sample.LiftJsonWithCollections$delayedInit$body.apply(LiftJsonWIthCollection.scala:8)
at scala.Function0$class.apply$mcV$sp(Function0.scala:34)
at scala.runtime.AbstractFunction0.apply$mcV$sp(AbstractFunction0.scala:12)
at scala.App$$anonfun$main$1.apply(App.scala:76)
at scala.App$$anonfun$main$1.apply(App.scala:76)
at scala.collection.immutable.List.foreach(List.scala:392)
at scala.collection.generic.TraversableForwarder$class.foreach(TraversableForwarder.scala:35)
at scala.App$class.main(App.scala:76)
at com.sample.LiftJsonWithCollections$.main(LiftJsonWIthCollection.scala:8)
at com.sample.LiftJsonWithCollections.main(LiftJsonWIthCollection.scala)
Не могу решить.
Я добавил следующую зависимость в pom
<dependency>
<groupId>net.liftweb</groupId>
<artifactId>lift-json_2.11</artifactId>
<version>3.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.json4s/json4s-jackson -->
<dependency>
<groupId>org.json4s</groupId>
<artifactId>json4s-jackson_2.11</artifactId>
<version>3.2.10</version>
</dependency>