【发布时间】:2012-07-13 18:07:24
【问题描述】:
我正在尝试使用Quartz plugin 在我的 Grails Web 应用程序中设置一个 cron 作业。我目前只是尝试使用以下代码每秒执行一次测试作业:
class TestJob {
private int counter = 0
static triggers = {
simple repeatInterval: 1000
}
def execute() {
// execute job
counter += 1
System.out.println("Testing the cron " + counter)
}
}
但是,当我运行该应用程序时,我只能看到第一个 execute() 调用的初始输出两次:一次是在我收到服务器正在运行的警报之前,一次是在之后。
| Loading Grails 2.1.0
| Configuring classpath.
| Environment set to development.....
| Packaging Grails application.....
| Compiling 1 source files.....
| Running Grails application
Testing the cron 1
| Server running. Browse to http://localhost:8080/QuartzTest
Testing the cron 1
有人知道为什么我的 Quartz 作业可能无法正确触发吗?我尝试过使用 cron 而不是 simple 以及使用不同的参数、时间间隔等。没有什么不同。
谢谢
【问题讨论】: