本篇文章给大家分享的是有关定时任务如何在Spring Boot中使用,小编觉得挺实用的,因此分享给大家学习,希望大家阅读完这篇文章后可以有所收获,话不多说,跟着小编一起来看看吧。spring Boot中配置定时任务import org.sp
本篇文章给大家分享的是有关定时任务如何在Spring Boot中使用,小编觉得挺实用的,因此分享给大家学习,希望大家阅读完这篇文章后可以有所收获,话不多说,跟着小编一起来看看吧。
spring Boot中配置定时任务
import org.springframework.context.annotation.Configuration;import org.springframework.scheduling.annotation.EnableScheduling;import org.springframework.scheduling.annotation.Scheduled;import java.text.SimpleDateFORMat;import java.util.Date;@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())); }}
--结束END--
本文标题: 定时任务如何在Spring Boot中使用
本文链接: https://www.lsjlt.com/news/226849.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
下载Word文档到电脑,方便收藏和打印~
2024-05-03
2024-05-03
2024-05-03
2024-05-03
2024-05-03
2024-05-03
2024-05-03
2024-05-03
2024-05-03
2024-05-03
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0