Cron expression to trigger on 25 of every month
How to write cron expression to trigger a function on 25th of every month at 9 A.M in the morning?
When I execute this code,
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
@Service
public class PayrollSchedulerImpl implements PayrollScheduler{
@Scheduled(cron="0 9 25 1 * ?")
public void calculateSalaryScheduled()
{
calculateSalary();
}
public void calculateSalary()
{
/* */
}
}
I get the error,
java.lang.StackOverflowError
sun.util.calendar.ZoneInfo.getOffsets(Unknown Source)
sun.util.calendar.ZoneInfo.getOffsets(Unknown Source)
java.util.GregorianCalendar.compu开发者_高级运维teFields(Unknown Source)
java.util.GregorianCalendar.computeTime(Unknown Source)
java.util.Calendar.updateTime(Unknown Source)
java.util.Calendar.complete(Unknown Source)
java.util.Calendar.get(Unknown Source)
org.springframework.scheduling.support.CronSequenceGenerator.doNext(CronSequenceGenerator.java:130)
@Scheduled(cron="0 9 25 1 * ?")
This is on January 1st only, and the time is invalid, you'll want this instead:
@Scheduled(cron="0 0 9 25 * ?")
Reference: CronSequenceGenerator
Corn that will trigger every 25th of each month.
@Scheduled(cron = "0 0 9 25 * ?")
use this link to validate the expression
https://www.freeformatter.com/cron-expression-generator-quartz.html
精彩评论