如何在运行时更改 Spring 的 @Scheduled fixedDelay? [英] How to change Spring's @Scheduled fixedDelay at runtime?

查看:69
本文介绍了如何在运行时更改 Spring 的 @Scheduled fixedDelay?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要以固定时间间隔运行批处理作业,并且能够在运行时更改此批处理作业的时间.为此,我遇到了 Spring 框架下提供的 @Scheduled 注释.但我不确定如何在运行时更改 fixedDelay 的值.我在谷歌上搜索了一些,但没有找到任何有用的东西.

I have a requirement to run a batch job at a fixed interval and have the ability to change the time of this batch job at runtime. For this I came across @Scheduled annotation provided under Spring framework. But I'm not sure how I'd change the value of fixedDelay at runtime. I did some googling around but didn't find anything useful.

推荐答案

您可以使用 Trigger 来动态设置下一次执行时间.在此处查看我的答案:

You can use a Trigger to dynamically set the next execution time. See my answer here:

以编程方式使用 Spring 调度作业(动态设置 fixedRate)

这篇关于如何在运行时更改 Spring 的 @Scheduled fixedDelay?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆