无法访问值akka.http.javadsl.unmarshalling中的Unmarshaller类型

知道不多

我正在尝试使用Akka Http Client API编写一个简单的Http客户端。为此,我编写了以下代码

import akka.actor.ActorSystem
import akka.http.scaladsl.Http
import akka.http.scaladsl.model._
import akka.http.scaladsl.unmarshalling._
import akka.stream.ActorMaterializer
import akka.stream.scaladsl.{Sink, Source}
import scala.concurrent.duration._
import scala.concurrent.{Await}
import akka.http.scaladsl.server.Directives
import akka.http.scaladsl.marshallers.sprayjson.SprayJsonSupport
import spray.json._

final case class Post(postId: Int, id: Int, name: String, email: String, body: String)

trait JsonSupport extends SprayJsonSupport with DefaultJsonProtocol {
   implicit val postFormat = jsonFormat5(Post.apply)
}

class AkkaHttpClient extends App with Directives with JsonSupport {
   implicit val system = ActorSystem("my-Actor")
   implicit val actorMaterializer = ActorMaterializer()
   implicit val executionContext = system.dispatcher
   val httpClient = Http().outgoingConnection(host="http://jsonplaceholder.typicode.com/")
   val flow = Source.single(HttpRequest(uri = Uri("/comments/1")))
      .via(httpClient)
      .mapAsync(1)(r => Unmarshal(r.entity).to[Post])
      .runWith(Sink.head)

   val results = Await.result(flow, 15 seconds)
   println(results)
}

我的build.sbt文件看起来像

name := "Akka-Http-Client"
version := "1.0"
scalaVersion := "2.11.8"
libraryDependencies ++= Seq(
   "com.typesafe.akka" %% "akka-http-experimental" % "2.4.9-RC1",
   "com.typesafe.akka" %% "akka-http-spray-json-experimental" % "2.4.9-RC1"
)

当我尝试编译代码时,出现这些错误

Error:scalac: missing or invalid dependency detected while loading class file 'Unmarshaller.class'.
Could not access type Unmarshaller in value akka.http.javadsl.unmarshalling,
because it (or its dependencies) are missing. Check your build definition for
missing or conflicting dependencies. (Re-run with `-Ylog-classpath` to see the problematic classpath.)
A full rebuild may help if 'Unmarshaller.class' was compiled against an incompatible version of akka.http.javadsl.unmarshalling.
弗拉迪斯拉夫·雷宾(Vladislav Rybin)

我在2.4.9-RC1上遇到了同样的问题,回落到2.4.8可以解决问题。

或者您可以使用此处描述的解决方法:https : //github.com/akka/akka/issues/21105

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

Angular-$ scope无法访问服务中的$ http响应

来自分类Dev

角度2:无法访问http请求中的响应头

来自分类Dev

Angular-$ scope无法访问服务中的$ http响应

来自分类Dev

无法访问 HTTP 服务器中的 POST 数据

来自分类Dev

无法访问JS对象中的值

来自分类Dev

无法访问结构数组中的值

来自分类Dev

无法访问JS对象中的值

来自分类Dev

无法访问$ modalInstance中的表单值

来自分类Dev

无法访问JSON对象中的值

来自分类Dev

在JavaScript中无法访问数组的值

来自分类Dev

无法访问表属性中的值

来自分类Dev

无法访问Controller中的$ data值

来自分类Dev

UWP - 无法访问 ItemsPanel 中的值

来自分类Dev

python无法访问列表中的值

来自分类Dev

无法访问对象中的值

来自分类Dev

无法访问nodejs中的数组值

来自分类Dev

Docker Akka-Http应用程序端点无法访问

来自分类Dev

通过HTTP端点在Akka群集中关闭无法访问的节点

来自分类Dev

在同一网络中无法访问 Ubuntu 中的 Http 服务器

来自分类Dev

无法访问 [AnyHashable:Any] 类型的值 - Swift 4

来自分类Dev

http4s路由模式匹配中的无法访问代码警告

来自分类Dev

无法访问指令中$ http.get设置的范围属性

来自分类Dev

hadoop中的NameNode未运行并且无法访问(http:// localhost:50030)

来自分类Dev

无法访问模板中Streamfield中的嵌套块的值

来自分类Dev

无法访问模板中Streamfield中的嵌套块的值

来自分类Dev

无法访问HTTP服务Intranet

来自分类Dev

无法访问 http://localhost:3000/

来自分类Dev

无法访问std :: map中的结构值

来自分类Dev

无法访问Switch Case / Java中的枚举值