spring schedule的简单实用
1.编写定时类。
@Component
public class test {
@Scheduled(cron = "0/2 * * * * ?")
public void test(){
System.out.println("aaa" + new Date());
}
}
2.启动。
在启动类中添加注解@EnableScheduling
效果如下。