1.介绍
作业调度,如定时任务
2.Cron表达式
7个占位符: 秒 分 时 日 月 周 年 (年通常省略)
Seconds, Minutes, Hours, Day-of-Month, Month, Day-of-Week, Year
3.Spring Schedule 配置
applicationContext.xml
<task:annotation-driven/> //task包
4.@Scheduled 写上 Cron表达式
@Autowired
private IOrderService iOrderService;
@Scheduled(cron = "0 */1 * * * ?")//没1分钟(每个1分钟的整数倍)
public void closeOrderTaskV1() {
log.info("关闭订单定时任务启动");
int hour = Integer.parseInt(PropertiesUtil.getProperty("close.order.task.time.hour", "2"));
iOrderService.closeOrder(hour);
log.info("关闭订单定时任务结束");
}