Java 定时任务调度XXL-JOB 入门实战

https://www.cnblogs.com/wuyongyin/p/14242162.html

@Component
public class TestJob {
    protected static Logger logger = LoggerFactory.getLogger(TestJob.class);

    @XxlJob("testJobHandler")
    public ReturnT<String> testJobHandler(String param) throws Exception {
        XxlJobLogger.log("test-JOB, Hello World.");

        for (int i = 0; i < 5; i++) {
            //XxlJobLogger打印的日志可以在控制台查看
            XxlJobLogger.log("beat at:" + i);
            logger.info("beat at:" + i);
            TimeUnit.SECONDS.sleep(2);
        }
        return ReturnT.SUCCESS;
    }
}

 

posted on 2022-05-07 16:27  悄悄的来,匆匆的走  阅读(295)  评论(0编辑  收藏  举报

导航