实例:
不生效的原因:
/**
* 1、简单任务示例(Bean模式)
*/
@XxlJob("demoJobHandler")
public ReturnT<String> demoJobHandler(String param) throws Exception {
XxlJobLogger.log("XXL-JOB, Hello World.");
for (int i = 0; i < 5; i++) {
try {
XxlJobLogger.log("beat at:" + i);
System.out.println("第"+i+"次");
TimeUnit.SECONDS.sleep(3);
}catch (Exception e){
e.printStackTrace();
}
}
return ReturnT.SUCCESS;
}
实例:正确写法
/**
* 1、简单任务示例(Bean模式)
*/
@XxlJob("demoJobHandler")
public ReturnT<String> demoJobHandler(String param) throws Exception {
XxlJobLogger.log("XXL-JOB, Hello World.");
for (int i = 0; i < 5; i++) {
try {
XxlJobLogger.log("beat at:" + i);
System.out.println("第"+i+"次");
TimeUnit.SECONDS.sleep(3);
}catch (Exception e){
if (e instanceof InterruptedException){
throw e;
}
}
}
return ReturnT.SUCCESS;
}
One comment
赞!混个脸熟,博客真好看ヾ(≧∇≦*)ゝ