定时任务框架,指定时间数据整理
xml设置
xmlns:task="http://www.springframework.org/schema/task"
http://www.springframework.org/schema/task
http://www.springframework.org/schema/task/spring-task-3.2.xsd
<task:annotation-driven />
定时处理类
1.加入 @component 加入容器, <context:component-scan 扫描
2.创建定时方法
@Scheduled(cron = "0/5 * * * * ? ")
public void taskCycle() {
System.out.println("使用SpringMVC框架配置定时任务");
}
@Scheduled
cron = "0/5 * * * * ? "
秒 分 时 天 月 周 年
* 每次
0 固有
? 不指定,忽略
- 表示区间
, 表示指定多个值
/ 用于递增触发
L 表示最后
W 表示离指定日期的最近那个工作日
#序号(表示每月的第几个周几)