spring Task基础(仅供自己参考)

    xiaoxiao2023-11-01  28

     

    前言

    此篇仅供自己参考,你们看不懂的,不要浪费时间

    spring Task 是定时任务,也就是任务调度

    同样的,还有Quartz   https://blog.csdn.net/yzj17025693/article/details/85028139

    spring Task是spring 内置的任务调度

     

    编写代码

    只需要在方法上加上 Scheduled,关键是表达式

    @Component public class SeckillTask { /** * 刷新秒杀商品 */ @Scheduled(cron="* * * * * ?") public void refreshSeckillGoods(){ System.out.println("执行了任务调度"+new Date()); } }

     

     

     

     

     

     

     

    最新回复(0)