Spring Scheduler does not work
Spring @Configuration (non-xml configuration) for annotation-driven tasks
Just add @EnableScheduling on your WebMvcConfig class
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Configuration
@EnableWebMvc
@EnableAsync
@EnableScheduling
public class WebMvcConfig implements WebMvcConfigurer {
/** Annotations config Stuff ... **/
}
If you want to use task:annotation-driven
approach and your @Scheduled annotation is not working, then you most probably missed context:component-scan
in your context xml.
Without this line, spring cannot guess where to search for your annotations.
<context:component-scan base-package="..." />