想吃苹果的蚂蚁的gravatar头像
想吃苹果的蚂蚁 2017-07-12 16:18:49
spring的quartz任务调度task

1 .建立任务,使用注解方式

@Component
public class QuartzJob1 {
    @Scheduled(cron="*/1 * * * * ?")
    public void run(){
        System.out.println("hello--->"+new Date());
    }
}

2在spring配置文件中配置


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

3.就可以测试使用了

 public static void main(String args[]){  
        AbstractApplicationContext context = new                      ClassPathXmlApplicationContext("applicationContext.xml");
        System.out.println(context);
    }  
   


打赏
最近浏览
想吃苹果的蚂蚁  LV9 2017年7月23日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友