Scheduled task in Spring Boot don't working

Viewed 246

I build simpy web api services application with Spring Boot, and I created some cron job service with Scheduled task in Spring Boot, but dont working. I need to run this service every week day [Monday-Friday] at 12:00(on day). That is a exmaple sheduling: @Scheduled(cron="0 1 1 ? * *")

2 Answers

Make sure you include the @EnableScheduling in your config:

@SpringBootApplication
@EnableScheduling
public class Application {

    public static void main(String[] args) {
        SpringApplication.run(Application.class);
    }
}

Cron should be

@Scheduled(cron = "0 0 0 * * MON-FRI")

Good example here

Check if you have added the @EnableScheduling annotation in the configuration class

@SpringBootApplication
@EnableScheduling
public class Application {

    public static void main(String[] args) {
        SpringApplication.run(Application.class);
    }
}

Check this https://spring.io/guides/gs/scheduling-tasks/

Related