前一段时间碰到个需要定时清理数据库字段的需求,网上找了半天一直在式quartz。
最后也没能成功,后来在网上看到一篇关于Spring 的@Scheduled定时任务配置起来十分简单,就在这做个记录。
(实现原理目前还没研究透,所以不做解释,只做记录。)
<1> 在Spring配置文件xmlns中加入
xmlns:task="http://www.springframework.org/schema/task"
<2>
在 xsi:schemLocation中加入
http://www.springframework.org/schema/task
http://www.springframework.org/schema/task/spring-task-4.0.xsd
<3>
<!-- 定时任务相关配置 -->
<task:annotation-driven executor="myExecutor" scheduler="myScheduler&#