首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Spring -任务调度器的问题

Spring -任务调度器的问题
EN

Stack Overflow用户
提问于 2011-08-24 21:51:32
回答 2查看 1.7K关注 0票数 0

我的任务调度程序有一个奇怪的问题。在我的appliacationContext.xml中有三个经过测试的pingProducer配置。第一个和第二个工作。第三个应该每小时产生一次ping,但不是-它每分钟产生一次ping。我是不是遗漏了什么?

代码语言:javascript
复制
<!-- Ping scheduler - WORKS - every second -->
<task:scheduled-tasks>
    <task:scheduled ref="pingProducer" method="producePingRequest" cron="* * * * * ?" />
</task:scheduled-tasks>

<!-- Ping scheduler - WORKS - every minute -->
<task:scheduled-tasks>
    <task:scheduled ref="pingProducer" method="producePingRequest" cron="0 * * * * ?" />
</task:scheduled-tasks>

<!-- Ping scheduler - DOES NOT WORK - every minute -->
<task:scheduled-tasks>
    <task:scheduled ref="pingProducer" method="producePingRequest" cron="0 0 * * * ?" />
</task:scheduled-tasks>
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2011-08-24 21:54:37

更改为:

代码语言:javascript
复制
<task:scheduled-tasks>
    <task:scheduled ref="pingProducer" method="producePingRequest" cron="50 0 * * * ?" />
</task:scheduled-tasks>

编辑:每小时一次,第50秒

票数 2
EN

Stack Overflow用户

发布于 2015-07-29 22:02:20

代码语言:javascript
复制
<task:scheduled-tasks>
<task:scheduled ref="pingProducer" method="producePingRequest" cron="0 0 0/1 * * ?" />
</task:scheduled-tasks>

cron="0 0 0/1 ** ?“之所以有效,是因为0/x表示从0点开始每隔x小时运行一次。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/7176564

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档