这篇文章主要介绍了Spring Boot定时任务的使用实例代码,需要的朋友可以参考下
Spring Boot中配置定时任务极其简单……下面看下实例代码:
import org.springframework.context.annotation.Configuration;import org.springframework.scheduling.annotation<strong style="color:transparent">本文来源gao@daima#com搞(%代@#码@网&</strong>.EnableScheduling;import org.springframework.scheduling.annotation.Scheduled;import java.text.SimpleDateFormat;import java.util.Date;/** * Created by winner_0715 on 2017/4/18. */@Configuration@EnableSchedulingpublic class SchedulingConfig { // 每5秒执行一次 @Scheduled(cron = "0/5 * * * * ?") public void scheduler() { System.out.println("SchedulingConfig.scheduler()" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date())); }}
以上就是Spring Boot实现定时任务的java代码实例的详细内容,更多请关注搞代码gaodaima其它相关文章!