1.首先需要添加在Spring的配置文件中添加命名空间和约束
xmlns:task="http://www.springframework.org/schema/task"
xsi:schemaLocation="http://www.springframework.org/schema/task
http://www.springframework.org/schema/task/spring-task-3.2.xsd“
2.添加定时任务注解驱动配置
<task:annotation-driven/>
3.在定时任务的类上加注解@component ,@Lazy(false),在定时任务的方法上加上@Scheduled(cron="0 00 18 * * ? "); 此执行job的时间可由你自己来指定(cron表达式内容)
转载请注明原文地址: https://ju.6miu.com/read-12042.html