本文介绍了Play 2.0的工作支持在哪里?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Play 1.0中,我们可以定义一些将在后台执行的作业:

In Play 1.0, we can define some jobs which will be executed in the background:

@OnApplicatonStart
@Every("1h")
public class DataJob extends Job {
    public void doJob() {
       // ...
    }
}

但是我在Play 2.0中找不到它.我想念什么吗?

But I can't find it in Play 2.0. Do I miss something?

推荐答案

修复了最初由 JonasAnso

要获取OnApplicationStart的功能,可以使用Global onStart

To obtain the functionality of OnApplicationStart you can use Global onStart

  • https://www.playframework.com/documentation/2.4.x/api/scala/index.html#play.api.GlobalSettings
  • https://www.playframework.com/documentation/2.4.x/api/java/play/GlobalSettings.html

您可以在此处使用Akka安排演员.

Here you can schedule your actors using Akka.

  • https://www.playframework.com/documentation/2.4.x/ScalaAkka
  • https://www.playframework.com/documentation/2.4.x/JavaAkka

希望有帮助.

这篇关于Play 2.0的工作支持在哪里?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-07 04:27