package cn.lili.controller.job;
|
|
import com.xxl.job.core.context.XxlJobHelper;
|
import com.xxl.job.core.handler.annotation.XxlJob;
|
import org.springframework.stereotype.Component;
|
|
import java.util.concurrent.TimeUnit;
|
|
/**
|
* @author:xp
|
* @date:2025/5/22 16:49
|
*/
|
@Component
|
public class TestJob {
|
|
// 简单任务示例
|
@XxlJob("demoJobHandler")
|
public void demoJobHandler() throws Exception {
|
XxlJobHelper.log("XXL-JOB, Hello World.");
|
|
// 执行你的业务逻辑
|
for (int i = 0; i < 5; i++) {
|
XxlJobHelper.log("beat at:" + i);
|
TimeUnit.SECONDS.sleep(2);
|
}
|
|
// 默认返回成功结果
|
}
|
|
}
|