本文介绍了Akka 2.1.2 Scheduler有问题(无法识别“系统”)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
根据这些示例,我正在尝试运行一个非常简单的循环函数循环:
I'm trying to get a very simple recurring function loop running, according to these samples:
doc.akka.io/docs/akka/2.1.2/scala/scheduler.html
代码:
import akka.actor.Actor import akka.actor.Props import scala.concurrent.duration._ object Main extends Application { val system = akka.actor.ActorSystem("system") // this was missing! import system.dispatcher system.scheduler.schedule( 0 milliseconds, (10*1000) milliseconds, { println( "click!" ) }) }我得到(sbt):
> .../src/Main.scala:34: not found: value system [error] import > system.dispatcher [error] ^ [error] > .../src/Main.scala:36: not found: value system [error] > system.scheduler.schedule( 0 milliseconds /*initial delay*/, > (entry.secs*1000) milliseconds /*delay between*/, { [error] ^系统应该来自哪里?
附录:
我在'main()'函数中包含代码,并且我没有不能从 Actor 或 ActorSystem 继承任何东西。重点是我想安排函数,但不参与Actor
I'm having the code within a 'main()' function, and I haven't inherited anything from Actor or ActorSystem. The point is I'd like to schedule functions but no go into actors with this. Is the framework thinking I must derive from something (if so, it kind-of should say it?).
推荐答案在 import system.dispatcher 之前似乎缺少以下表达式:
It looks like missing of following expression before import system.dispatcher:
val system = akka.actor.ActorSystem("system")更多推荐
Akka 2.1.2 Scheduler有问题(无法识别“系统”)
发布评论