使用 Akka 和 sbt 启用波浪号触发器
Enable tilde trigger with Akka and sbt
使用 sbt 可以在源更改时进行 ~运行 重新编译和 运行 程序。但是,一旦创建了 ActorSystem,它就不再起作用了。
当系统关闭时它可以工作,但我不想关闭系统。
import akka.actor.ActorSystem
object Test {
def main(args: Array[String]) : Unit = {
val system = ActorSystem()
// if this line is removed, source code detection is disabled
system.shutdown()
}
}
有什么解决方法吗?
你必须记住 SBTs ~run
本身是 而不是 热重载,它只是 "once the process finishes, run it again please"。 Akka 的线程池是非守护进程的,这意味着在 ActorSystem 为 "alive" 之前程序不会终止,因此 SBT 的 ~run
不会再次触发。
相反,您可能想查看 sbt-revolver SBT 插件,它可以满足您的需求(包括基于 Akka 的应用程序)。
使用 sbt 可以在源更改时进行 ~运行 重新编译和 运行 程序。但是,一旦创建了 ActorSystem,它就不再起作用了。
当系统关闭时它可以工作,但我不想关闭系统。
import akka.actor.ActorSystem
object Test {
def main(args: Array[String]) : Unit = {
val system = ActorSystem()
// if this line is removed, source code detection is disabled
system.shutdown()
}
}
有什么解决方法吗?
你必须记住 SBTs ~run
本身是 而不是 热重载,它只是 "once the process finishes, run it again please"。 Akka 的线程池是非守护进程的,这意味着在 ActorSystem 为 "alive" 之前程序不会终止,因此 SBT 的 ~run
不会再次触发。
相反,您可能想查看 sbt-revolver SBT 插件,它可以满足您的需求(包括基于 Akka 的应用程序)。