【发布时间】:2018-05-04 17:49:49
【问题描述】:
我使用 Akka HTTP 作为客户端来执行 POST 请求并解析答案。我正在使用 Play JSON,但出现以下编译器错误:
could not find implicit value for parameter um: akka.http.scaladsl.unmarshalling.Unmarshaller[akka.http.javadsl.model.ResponseEntity,B]
[ERROR] Unmarshal(response.entity).to[B].recoverWith {
这是我添加的使用 Play JSON 而不是 Spray 的依赖项:
"de.heikoseeberger" %% "akka-http-play-json"
我的班级定义是:
class HttpClient(implicit val system: ActorSystem, val materializer: Materializer) extends PlayJsonSupport {
方法定义为:
private def parseResponse[B](response: HttpResponse)(implicit reads: Reads[B]): Future[B] = {
if (response.status().isSuccess) {
Unmarshal(response.entity).to[B].recoverWith {
....
在我拥有的进口商品中:
import play.api.libs.json._
import scala.concurrent.ExecutionContext.Implicits.global
import de.heikoseeberger.akkahttpplayjson.PlayJsonSupport._
在我看来,我在范围内具有所需的隐式。 Marshal 部分具有类似的逻辑(但使用Writes 而不是Reads)并且编译良好。我错过了什么?
【问题讨论】:
标签: scala unmarshalling akka-http play-json