Spring Boot-Schedule a task with SpringBoot-Download Source Code
Hello everyone, today we will learn how to schedule tasks in Spring Boot using @Scheduled annotation. To schedule jobs in the spring boot application to run periodically, spring boot provides @EnableScheduling and @Scheduled annotations. Add @EnableScheduling to Spring Boot Application class Add @EnableScheduling annotation to your spring boot application class. @EnableScheduling is a Spring Context module annotation. It internally imports the SchedulingConfiguration via the @Import(SchedulingConfiguration.class) instruction @ SpringBootApplication @ EnableScheduling public class KnowledgefactoryScheduler { public static void main( String [] args) { SpringApplication.run(KnowledgefactoryScheduler.class, args); } } 1. Scheduling a Task with Fixed Rate You can schedule a method to be executed at a fixed interval by using fixedRate parameter in the @Scheduled annotation. In the following example, The annotated method