Spring Boot的定时任务
主要讨论几种在Spring Boot下常见的定时器使用。
1、基于注解(@Scheduled)
// An highlighted block
package com.example.dbandcache.scheduler;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import java.time.LocalDateTime;
@Component
@EnableScheduling