1
只是嘗試了噴霧JSON,它似乎有問題找到我的JsonProtocols我已經設置。我有以下的依存關係:Marshaller沒有找到
"io.spray" % "spray-servlet" % "1.2-M8",
"io.spray" % "spray-routing" % "1.2-M8",
"io.spray" % "spray-testkit" % "1.2-M8",
"io.spray" % "spray-json_2.10" % "1.2.5"
以下代碼:
Content.scala
import spray.json.DefaultJsonProtocol
case class Content(id:String, name: String, contentType: String, duration: Int)
object MyJsonProtocol extends DefaultJsonProtocol {
implicit val contentFormat = jsonFormat4(Content)
}
我得到的地方,我在complete {}
塊返回Content
行了,錯誤的錯誤如下,代碼如下:
描述離子資源路徑位置類型 找不到類型spray.httpx.marshalling.Marshaller [內容] MyService.scala線32斯卡拉問題的證據參數
import akka.actor.Actor
import spray.routing._
import spray.http._
import MediaTypes._
import spray.json.DefaultJsonProtocol
import Content
import MyJsonProtocol._
class MyServiceActor extends Actor with MyService{
def actorRefFactory = context
def receive = runRoute(myRoute)
}
trait MyService extends HttpService {
val myRoute =
path("") {
get {
respondWithMediaType(`application/json`) { // XML is marshalled to `text/xml` by default, so we simply override here
complete {
new Content("1234", "Some Content", "YT", 60)
}
}
}
}
}
任何人都可以看到什麼問題隱含的價值?這是字面上的噴霧模板代碼在
灑噴霧JSON的東西
非常好,謝謝Alex。我錯過了文檔中的關鍵點,是否在spray.io上? – ThaDon