spring task:annotation-driven 定时任务

1、配置文件加上<task:annotation-driven/>

2、要运行的方法前加上

@Scheduled(cron="0 00 12 1 * ?")  //每月1号中午12:00执行
 public void demo(){
   Date date=new Date(); 
         SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd hh:mm:ss"); 
         System.out.println("================"+sdf.format(date)); 
 }

原文地址:https://www.cnblogs.com/sprinng/p/5057453.html