等級:備忘
技術含量: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表達式