zl程序教程

您现在的位置是:首页 >  后端

当前栏目

spring定时任务

Spring 任务 定时
2023-09-11 14:18:37 时间

https://blog.csdn.net/aspnet2002web/article/details/52810569

错误一

使用Quartz任务调用的时候报错Based on configured schedule, the given trigger will never fire.

org.quartz.SchedulerException: Based on configured schedule, the given trigger will never fire.

大概意思是设置的触发器时间比当前时间小,永远不会触发,所以需要修改触发时间

错误二

在使用调度器的时候,遇到了如下的错误:

Support for specifying both a day-of-week AND a day-of-month parameter is not implemented.

这个错误的原因就是因为你的Cron表达式配置错误了: 
即,你把日期和周同时指定了值(*也代表指定值,只是任意值而已)

你的配置可能是:0 18 17 * * ,或者0 18 17 * 2-6,或者0 18 17 10 * 2-6等等。

如果你的日期和周同时为?会报如下错误:

'?' can only be specfied for Day-of-Month -OR- Day-of-Week.

总结:当我们配置日期和周时,我们应该注意只能指定二者中的一个,另一个必须为?。如:0 18 17 * * ?或者0 18 17 ? * 2-6等等。