Scheduler not running in Spring Boot

I was able to solve the issue, I forgot to provide @service level annotation, I have created the check List for @Scheduler, kindly go through every point one by one, It will help you to solve the issue.

  1. Check for the @EnableScheduling on SpringBoot Main class.
  2. Scheduled method should be annotated with @Scheduled, Follow the @Scheduled Method rules. a method should have the void return type, a method should not accept any parameters.
  3. Make sure the class should be annotated with @Service or @Component Annotation so SpringBoot can make the object of that class.
  4. The package of the scheduler jobs should be under the main Application class's package. e.g com.company is your main application class package then scheduler class package should be com.company.scheduler,
  5. If you are using Cron expression confirm the same e.g @Scheduled( cron = "0 0/2 * * * ?"), This Cron expression will schedule the task for every 2 min.

Feel free to add more points in the comment so it will help to solve the issue.


May be you can solve this problem by adding the @ComponentScan annotation in the configuration file

@SpringBootApplication
@EnableScheduling
@ComponentScan(basePackages = "com.mk.service")
@PropertySource("classpath:application.properties")
public class EnverseDemoApplication {

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