Ivan Ivanov
Ivan Ivanov

Reputation: 203

Scheduled task in Spring Boot don't working

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 ? * *")

Upvotes: 2

Views: 319

Answers (2)

Essex Boy
Essex Boy

Reputation: 7940

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

Upvotes: 2

mav
mav

Reputation: 137

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/

Upvotes: 1

Related Questions