开启注解
@EnableScheduling //开启定时功能的注解
创建定时任务
在需要执行的定时任务上加上注解@Scheduled(cron = "0 51 15 * * ?")
其中corn表示你要在什么时间执行的属性。具体表达式见
Cron表达式生成器
//在一个特定的时间执行这个方法
//秒 分 时 日 月 周几~
@Scheduled(cron = "0 51 15 * * ?")
public void hello(){
System.out.println("hello,你被执行了");
}