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: java.lang.IllegalStateException: Encountered invalid @Scheduled method 'clearRps': Cron expression must consist of 6 fields (found 7 in "0 0/15 * 1/1 * ? *")
Spring boot provides @EnableScheduling and @Scheduled annotations, to schedule cron jobs in the spring boot application which runs periodically. Let's learn, how to use Spring boot @Scheduled annotation. Add @Scheduled annotations on methods that you want to schedule.
We can turn any method in a Spring bean for scheduling by adding the @Scheduled annotation to it. The @Scheduled is a method-level annotation applied at runtime to mark the method to be scheduled. It takes one attribute from cron , fixedDelay , or fixedRate for specifying the schedule of execution in different formats.
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).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With