小编Tes*_*ult的帖子

Spring 计划的 cron 作业运行次数过多

我的作业每隔指定的时间运行一次,但它每隔指定的时间运行一次,例如,如果我将作业设置为在 22:54 运行,它将从 22:54:00 到 22:54:59 每秒运行一次。我希望它只在指定的时间运行一次...非常感谢任何帮助

我的代码:

@Scheduled(cron = "* 54 22 * * ?")
    public void getCompaniess() {
         System.out.println(new Date()+" > Running testScheduledMethod...");

    }
Run Code Online (Sandbox Code Playgroud)

输出: Thu Mar 12 22:54:00 GMT 2020 > Running testScheduledMethod... Thu Mar 12 22:54:01 GMT 2020 > Running testScheduledMethod... ..... Thu Mar 12 22:54:59 GMT 2020 > Running testScheduledMethod...

cron spring-scheduled spring-boot

6
推荐指数
1
解决办法
1585
查看次数

标签 统计

cron ×1

spring-boot ×1

spring-scheduled ×1