spring项目一些简单的定时任务可以通过@Schedule注解来实现,具体配置如下
在applicationContext.xml文件中增加配置
1.引入task约束
xmlns:task="http://www.springframework.org/schema/task"
2.schemaLocation中引入schema文件
http://www.springframework.org/schema/task
http://www.springframework.org/schema/task/spring-task-3.0.xsd
3.增加配置
<task:annotation-driven />
4.在执行定时任务的类文件上增加注解 @EnableScheduling、@Component/@Service(根据实际用的形式选择注解方式)