import java.time.LocalDateTime; import org.springframework.context.annotation.Configuration; import org.springframework.scheduling.annotation.EnableScheduling; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; @Component @Configuration // 1. Tag Configuration class is mainly used, both the effect of Component. @EnableScheduling // 2. opening timing task public class SaticScheduleTask { // 3. Add timer task @Scheduled (the cron = "* * * * 0/60?" ) // or direct a specified time interval, for example: 5 seconds // @Scheduled (fixedRate = 5000) Private void configureTasks () { System.err.println ( "regular tasks to perform static time:" + LocalDateTime.now ()); } }