加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

spray.io如何使用scala 2.11.1 akka 2.3.2

发布时间:2020-12-16 18:07:56 所属栏目:安全 来源:网络整理
导读:我想使用spala 2.11.x akka 2.3.x的spray.io,我在spray.io的Project Info页面中找到以下内容: spray 1.3.1 is built against Scala 2.10.3 and Akka 2.3.0 as well as Scala 2.11.1 and Akka 2.3.2. 当我使用spray-client时,我遇到了一些问题然后我在spray.
我想使用spala 2.11.x akka 2.3.x的spray.io,我在spray.io的Project Info页面中找到以下内容:

spray 1.3.1 is built against Scala 2.10.3 and Akka 2.3.0 as well as Scala 2.11.1 and Akka 2.3.2.

当我使用spray-client时,我遇到了一些问题然后我在spray.io的Documentation页面中找到了以下内容:spray-client依赖于akka 2.10.x:

akka-actor 2.2.x (with ‘provided’ scope,i.e. you need to pull it in yourself)

提供的范围意味着什么?如何将它与scala 2.11.x akka 2.3.x中编写的程序的其他部分一起使用?

编辑

以下是documentation page中列出的最简单的用例:

import akka.actor.ActorSystem
import scala.concurrent.Future
object main {
  def main(args: Array[String]) {
    import spray.http._
    import spray.client.pipelining._
    implicit val system = ActorSystem()
    import system.dispatcher // execution context for futures
    val pipeline: HttpRequest => Future[HttpResponse] = sendReceive
    val response: Future[HttpResponse] = pipeline(Get("http://spray.io/"))
  }
}

使用build.sbt:

scalaVersion := "2.11.1"
libraryDependencies += "com.typesafe.akka" %% "akka-actor" % "2.3.2"
libraryDependencies += "io.spray" % "spray-client" % "1.3.1"

虽然编译得很好,但它符合运行时错误:

Uncaught error from thread [default-akka.actor.default-dispatcher-2] shutting down JVM since 'akka.jvm-exit-on-fatal-error' is enabled for ActorSystem[default]
java.lang.NoClassDefFoundError: scala/runtime/AbstractPartialFunction$mcVL$sp
  at ...

解决方法

提供的依赖性意味着,spray需要依赖性,但希望开发人员在其构建配置中提供它.因此,您需要在构建配置中添加akka-actor.

如果您使用的是sbt,则可以将以下行添加到依赖项中.

"com.typesafe.akka"     %% "akka-actor"         % 2.3.2,

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读