首页 > 编程语言 > 详细

Spring定时器

时间:2015-05-17 21:52:26      阅读:175      评论:0      收藏:0      [点我收藏+]

等级:备忘

技术含量: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表达式

Spring定时器

原文:http://blog.csdn.net/zhang6622056/article/details/45796579

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!