scala - When I convert an object to json with json4s in a SBT task, it reports errors, how to fix? -
i'm writing sbt task, convert objects json , output, has errors. code is:
project/plugins.sbt
librarydependencies ++= seq( "org.scala-lang" % "scalap" % "2.10.4", "org.json4s" %% "json4s-native" % "3.2.6", "org.json4s" %% "json4s-core" % "3.2.6", "org.json4s" %% "json4s-ext" % "3.2.6" )
build.sbt
name := "json4s-210-test" version := "1.0" scalaversion := "2.10.4" import scala.tools.scalap.scalax.rules.scalasig.scalasigsymbol lazy val json = taskkey[unit]("output json json4s") json := { case class config(name: string) case class project(name: string, configs: seq[config]) implicit val formats = org.json4s.defaultformats val project = project("myproject", seq(config("conf1"))) val json = org.json4s.native.serialization.write(project) println(json) }
when run sbt json
, reports error:
➜ json4s-210-test git:(master) ✗ ./sbt [info] loading global plugins /users/twer/.sbt/0.13/plugins [info] loading project definition /users/twer/workspace/json4s-210-test/project [info] set current project json4s-210-test (in build file:/users/twer/workspace/json4s-210-test/) > json [trace] stack trace suppressed: run last *:json full output. [error] (*:json) java.lang.noclassdeffounderror: scala/tools/scalap/scalax/rules/scalasig/scalasigsymbol [error] total time: 0 s, completed may 14, 2015 1:19:58 pm > last java.lang.noclassdeffounderror: scala/tools/scalap/scalax/rules/scalasig/scalasigsymbol @ org.json4s.reflect.reflector$classdescriptorbuilder$$anonfun$constructorsandcompanion$3$$anonfun$13.apply(reflector.scala:123) @ org.json4s.reflect.reflector$classdescriptorbuilder$$anonfun$constructorsandcompanion$3$$anonfun$13.apply(reflector.scala:122) @ scala.collection.traversablelike$$anonfun$map$1.apply(traversablelike.scala:244) @ scala.collection.traversablelike$$anonfun$map$1.apply(traversablelike.scala:244) @ scala.collection.mutable.resizablearray$class.foreach(resizablearray.scala:59) @ scala.collection.mutable.arraybuffer.foreach(arraybuffer.scala:47)
but can see i've alread add dependency:
"org.scala-lang" % "scalap" % "2.10.4"
and imported required class in build file:
import scala.tools.scalap.scalax.rules.scalasig.scalasigsymbol
why there such error , how fix it?
update: can clone code , try here: https://github.com/freewind/json4s-210-test
Comments
Post a Comment