gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-01 12:39:09 27 4
gpt4 key购买 nike

我正在 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/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com