2019独角兽企业重金招聘Python工程师标准>>>
一:添加maven依赖。
二:有一个定时任务类,以及定时执行的方法。
import java.text.SimpleDateFormat;
import java.util.Date;/*** 定时任务类* @author **/
public class Job {public void execute(){SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");String date = sdf.format(new Date());System.out.println(date + " 执行Job--------");}
}
三:在spring的配置文件中添加相关配置。
四:web.xml的配置。