Reputation: 71
I am trying to run this job in spring but i am getting an error
My intention is to run the job last Friday of every month
@EnableScheduling
@Service
public class TestSchedular {
@Scheduled(cron= "0 0 0 ? * 6L")
public void schedular() {
System.out.println("Cron Job");
}
Error:
Caused by: java.lang.IllegalStateException: Encountered invalid @Scheduled method 'schedular': For input string: "6L"
What is wrong with this code?
Upvotes: 0
Views: 401
Reputation: 3724
Your cron expression ("0 0 0 ? * 6L") is invalid.
Spring's CronSequenceGenerator class has a method isValidExpression(String expression) which takes the cron expression and returns a boolean.
You could use that to check your Cron expression.
Upvotes: 1