第一步:在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.1.xsd
第二步:配置文件中 引入 定时任务注解
<task:annotation-driven/>
<context:annotation-config/>
<bean class="org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor"/>
<context:component-scan base-package="com.test"/>
其中 base-package 定义要扫描的基础包第三步:创建业务定时任务类
注意:
1.该类要加上@Component 注解标签
2.方法上加上@Scheduled(cron="0/5 * * * * ? ")注解标签