Akka 2.1.2 Scheduler有问题(无法识别“系统”)

编程入门 行业动态 更新时间:2024-10-08 12:39:26
本文介绍了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有问题(无法识别“系统”)

本文发布于:2023-11-25 18:02:43,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1630773.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:无法识别   系统   Akka   Scheduler

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!