【发布时间】:2013-11-06 10:45:08
【问题描述】:
更新到 spray 1.2 后,我遇到了一个与 1.1 完美配合的 JSON-Marshallers 的问题。在 HttpService 中执行以下操作
trait TestHttpService extends HttpService with SprayJsonSupport with DefaultJsonProtocol{ self : ActorLogging =>
case class Test(hallo: String, test: String)
implicit val storyJsonFormat = jsonFormat2(Test.apply)
def test(implicit m : Marshaller[Future[Test]]) = 17
def hallo = test
}
导致以下错误:
could not find implicit value for parameter marshaller:
spray.httpx.marshalling.Marshaller[scala.concurrent.Future[amanuensis.story.Story]]
当我删除未来时,一切正常:
trait TestHttpService extends HttpService with SprayJsonSupport with DefaultJsonProtocol { self : ActorLogging =>
case class Test(hallo: String, test: String)
implicit val storyJsonFormat = jsonFormat2(Test.apply)
def test(implicit m : Marshaller[Test]) = 17
def hallo = test
}
所以 Story 本身的 Marshaller 似乎在隐式范围内。我现在很困惑,因为我以前从来不需要做任何其他事情来编组期货。
我真的很感激一个提示,我在这里做错了什么......
【问题讨论】:
-
版喷版是这样的吗?
-
Spray-Version 是 1.2-RC2,但当前的夜间版本也是如此。 Akka 是 2.2.3,Scala 是 2.10.3。
-
刚刚添加了case类定义和JsonFormat的定义...