gpt4 book ai didi

grails - Grails 的 Quartz 工作只触发一次

转载 作者:行者123 更新时间:2023-12-04 16:54:33 25 4
gpt4 key购买 nike

我正在尝试使用 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 而不是简单的,以及使用不同的参数、时间间隔等。没有任何区别。

谢谢

最佳答案

我想我有类似的问题。您不得使用 System.out.println从 quartz 作业中。尝试使用 log.error .

关于grails - Grails 的 Quartz 工作只触发一次,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11475944/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com