简体   繁体   中英

Spring execute method every 15 minutes

I tried to use cron expression from this site http://www.cronmaker.com/

@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 * ? *")

Just use the following cron:

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

Spring cron expression syntax slightly differs from unix cron expression. One immediate difference - it supports 1 less field (6 rather than 7).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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