楚落凡尘

一个简单的Quartz定时任务

package com.shuadan.quartz;

import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

@Component
public class GlodQuartz {
     /**
     * 每隔2秒执行
     */
    @Scheduled(cron = "*/2 * * * * ? ")
    public void addUserGold() {
        System.out.println("搞事情?");
    }
    
}

springMVC-mvc.xml添加配置声明

xmlns:task="http://www.springframework.org/schema/task"
xsi:schemaLocation="
 http://www.springframework.org/schema/task 
 http://www.springframework.org/schema/task/spring-task.xsd"

 

<task:annotation-driven />
<context:component-scan base-package="com.shuadan.quartz"/>

 

posted on 2018-12-19 14:01  楚落凡尘  阅读(162)  评论(0编辑  收藏  举报

导航