1
@Scheduled(cron = "0/20 * * * * ? 2005")
    public void execute(){
        System.out.println("ITs running...");
    }

Encountered invalid @Scheduled method 'execute': Cron expression must consist of 6 fields (found 7 in "0/20 * * * * ? 2005")

When I am trying to use 7 fields within the cron expression I am getting this error. Could anyone help me to resolve this issue please?

Onkar Musale
  • 909
  • 10
  • 25
preetk
  • 13
  • 3

1 Answers1

3

@Scheduled supports six fields when using cron expression. As per CronSequenceGenerator docs it doesn't support a year field:

The pattern is a list of six single space-separated fields: representing second, minute, hour, day, month, weekday. Month and weekday names can be given as the first three letters of the English names.

Karol Dowbecki
  • 43,645
  • 9
  • 78
  • 111