scala - IO(Http) 是导致错误 "could not find implicit value for parameter system: akka.actor.ActorSystem"

标签 scala akka spray

我正在 scala 中构建一个喷雾应用程序,我正在按照找到的示例进行操作 here但是当我去编译时,我得到了这个错误

Error:(38, 7) could not find implicit value for parameter system: akka.actor.ActorSystem
                IO(Http) ! Http.Bind(webServer,
                  ^

谷歌搜索没有把我带到哪里,这是我的应用程序的代码

package au.net.hivemedia.polydeploy

import akka.actor.{Props, ActorRef, ActorSystem}
import akka.io.IO
import au.net.hivemedia.polydeploy.dono.http.WebServerActor
import spray.can.Http

/**
 * PolyDeploy Dono - Braeburn
 *
 * Copyright (c) Hive Media Production, 2014.
 * All rights reserved. Do not redistribute
 *
 */
object App extends App {

  final val VERSION = "1.0-SNAPSHOT"
  final val CODENAME = "Twilight Sparkle"

  private var instance: Dono = _
  private var actorSystem: ActorSystem = _
  private var webServer: ActorRef = _

  override def main(args: Array[String]) {
    println("Starting PolyDeploy Dono v" + VERSION)
    println("=+ Project Version Codename: " + CODENAME)

    instance = new Dono()
    println("=+ Loading required items into the runtime")
    instance.load()

    println("=+ Loading new Actor System")
    actorSystem = ActorSystem("DonoActorSystem")

    println("=+ Starting web interface server")
    webServer = actorSystem.actorOf(Props[WebServerActor], name = "WebServer")

    IO(Http) ! Http.Bind(webServer,
                         interface = instance.getConfiguration().getString("web-bind-host"),
                         port = instance.getConfiguration().getInt("web-bind-port"))

  }
}

如果需要,我可以发布更多代码片段

谢谢,

利亚姆

最佳答案

IO.apply 采用隐式 ActorSystem。通过使用 implicit var actorSytem 使 actorSystem 成为隐式的,或者将 actorSystem 作为 IO(Http)(actorSystem) 显式传递

关于scala - IO(Http) 是导致错误 "could not find implicit value for parameter system: akka.actor.ActorSystem",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26735649/

相关文章:

scala - akka http 没有正确处理带有美元符号的参数?

scala - 如何创建一个可以稍后通过方法调用接收元素的 Source?

scala - Spray.io - 将处理委托(delegate)给另一个参与者

java - 使用 spray 服务分层静态内容

scala - parboiled2 和 Spray 导致跨版本后缀冲突

scala - 简单esRDD(Spark中使用的Elasticsearch-hadoop连接器)引发了异常

scala - akka http、字符集 header 、utf-8 问题

scala - 防止 sbt 发布自动聚合的根项目

scala - 将结果主体反序列化为 json 响应的字节数组

scala - 列表中相同位置的平均值