我在用着
val akkaV = "2.2.3"
val sprayV = "1.2.0"
Seq(
"io.spray" % "spray-can" % sprayV,
"io.spray" % "spray-routing" % sprayV,
"io.spray" %% "spray-json" % "1.2.5",
"io.spray" % "spray-testkit" % sprayV,
"com.typesafe.akka" %% "akka-actor" % akkaV,
"com.typesafe.akka" %% "akka-testkit" % akkaV,
并得到这个错误:
找不到参数编组器的隐式值:spray.httpx.marshalling.ToResponseMarshaller[List[org.bwi.models.Cluster]]
使用此代码:
object JsonImplicits extends DefaultJsonProtocol {
val impCluster = jsonFormat2(Cluster)
}
trait ToolsService extends HttpService with spray.httpx.SprayJsonSupport {
val myRoute = {
import JsonImplicits._
path("") { get { getFromResource("tools.html") } } ~
pathPrefix("css") { get { getFromResourceDirectory("css") } } ~
pathPrefix("fonts") { get { getFromResourceDirectory("fonts") } } ~
pathPrefix("js") { get { getFromResourceDirectory("js") } } ~
path("clusters") {
get {
complete {
val result: List[Cluster] = List(Cluster("1", "1 d"), Cluster("2", "2 d"), Cluster("3", "3 d"))
result //***** ERROR OCCURS HERE *****
}
}
}
}
}
我已经尝试过关于这个问题的建议,但没有奏效,同样的错误。
我似乎无法弄清楚我需要导入的隐含内容是什么。任何帮助,将不胜感激。