@EnableScheduling
时间: 2023-10-23 18:48:01 浏览: 39
@EnableScheduling is an annotation used in Spring Framework to enable scheduling of tasks. It is used to configure the scheduling infrastructure and to enable the scheduling of methods annotated with @Scheduled.
When this annotation is added to a Spring configuration class, Spring Framework will detect it and create a TaskScheduler bean that can be used to schedule tasks. This annotation is used in conjunction with @Scheduled annotation to schedule a method to be executed at a specific time interval.
For example, if we have a method that needs to be executed every 5 seconds, we can annotate it with @Scheduled(fixedRate = 5000) and Spring will automatically schedule it to run every 5 seconds.
Overall, @EnableScheduling is an important annotation used in Spring Framework to enable the scheduling of tasks and automate the execution of methods at specific intervals.