1、添加jar包
<dependency>
<groupId>it.sauronsoftware.cron4j</groupId>
<artifactId>cron4j</artifactId>
<version>2.2.5</version>
<scope>provided</scope>
</dependency>
2、创建HelloTask
public class HelloTask extends Task {
@Override
public void execute(TaskExecutionContext context) throws RuntimeException {
System.err.println("hello task"+ new Date());
}
}
3、在MainConfig中
Cron4jPlugin cp = new Cron4jPlugin();
cp.addTask("*/1 * * * *", new HelloTask());
me.add(cp);
注:https://www.jianshu.com/p/1888a4c7d873