简体   繁体   English

Spring 每 15 分钟执行一次方法

[英]Spring execute method every 15 minutes

I tried to use cron expression from this site http://www.cronmaker.com/我试图从这个网站http://www.cronmaker.com/使用 cron 表达式

@Scheduled(cron = "0 0/15 * 1/1 * ? *")
    public void clearRps() {

    }

But it throws by: java.lang.IllegalStateException: Encountered invalid @Scheduled method 'clearRps': Cron expression must consist of 6 fields (found 7 in "0 0/15 * 1/1 * ? *")但它抛出: java.lang.IllegalStateException: Encountered invalid @Scheduled method 'clearRps': Cron expression must include 6 fields (found 7 in "0 0/15 * 1/1 * ? *")

Just use the following cron:只需使用以下 cron:

@Scheduled(cron = "0 0/15 * * * *")

Spring cron expression syntax slightly differs from unix cron expression. Spring cron 表达式语法与 unix cron 表达式略有不同。 One immediate difference - it supports 1 less field (6 rather than 7).一个直接的区别 - 它支持少 1 个字段(6 个而不是 7 个)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM