1

我有一个管道:

import spray.httpx.unmarshalling._
import spray.client.pipelining._
import spray.json._
import MyJsonProtocol._ //which defines a formatter for MyCustomType
import spray.http._
import spray.httpx.SprayJsonSupport._

val pipeline = sendReceive ~> unmarshal[MyCustomType]

编译器说他不能find implicit value for parameter unmarshaller: spray.httpx.unmarshalling.FromResponseUnmarshaller[MyCustomType]

我已经像在此处的喷雾文档中的示例中那样完成了它。为什么它不能解决隐含?

EDIT val pipeline = sendReceive ~> unmarshal[MyCustomType]用于匿名类的方法。我发现如果我在那个匿名类中声明我的所有 jsonFomats(我的意思是MyJsonProtocol我替换为匿名类的东西)一切正常。

所以问题是为什么这不适用于匿名类?

4

1 回答 1

1

尝试指定值管道的类型:

val pipeline: HttpRequest => Future[MyCustomType] = sendReceive ~> unmarshal[MyCustomType]
于 2015-06-22T23:03:16.320 回答