等级:备忘
技术含量:LOW
使用:
1、XML配置:
<pre name="code" class="html">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"/>
2、JAVA实现类
@Component
public class DataTask {
//@Scheduled(cron="0 */5 * * * ?") //每5分钟执行一次
//@Scheduled(cron="0/5 * * * * ?") //每5秒执行一次
//@Scheduled(cron="0 13 */1 * * ?") //每小时执行一次
@Scheduled(cron="0 13 */1 * * ?") //每小时执行一次刷新微信分享缓存
public void dataStart(){
}
}
3、说明:
1、实现类注解@Component
2、实现方法注解@Scheduled
3、定时器时间表达式corn表达式