• springboot 定时任务


    时间参数参考:

    https://www.cnblogs.com/Rain1203/p/11699420.html

    1、程序开启入口

    @SpringBootApplication
    @EnableScheduling
    public class Application {
    
        public static void main(String[] args) {
            SpringApplication.run(Application.class, args);
        }
    
    }
    @EnableScheduling

    2、定时任务

    @Configuration
    @EnableScheduling
    public class DeleteCutImgSchedule {
    
        @Autowired
        private TpWisdomCutImgInfoMapper tpWisdomCutImgInfoMapper;
    
        @Scheduled(cron = "0/5 * * * * *")
        public void cron(){
            DateUtils dateUtils = new DateUtils();
            String beforeCustomDate = dateUtils.getBeforeCustomDate(2);
            System.out.println("=================");
            tpWisdomCutImgInfoMapper.deleteCutImgInfo(beforeCustomDate);
            System.out.println("+++++++++++++++++");
        }
    }

     吐槽:

    希望Django工程师加强Schedule的开发,不能别SpringBoot落下

  • 相关阅读:
    day11
    day10
    day9
    day8
    day7
    day6
    day14
    day13
    day12
    day11
  • 原文地址:https://www.cnblogs.com/wt7018/p/13706353.html
Copyright © 2020-2023  润新知