首页 > 编程语言 > 详细

springMVC 定时器配置

时间:2018-04-09 11:34:29      阅读:189      评论:0      收藏:0      [点我收藏+]

1、在springMVC中加入

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

2、添加定时器开关

<task:annotation-driven />

3、项目启动扫描包(我下面是多个包)

<context:component-scan base-package="com.xxx.controller,com.xxx.task"/>

4、

@Component
public class CreatTablesTask {
    
    @Autowired
    private CdrService cdrService;
    
    // 每月一号凌晨两点执行任务
   // @Scheduled(cron = "0 0  2  1 *  ? *")

  //没分钟执行一次 @Scheduled(cron = "0 0/1 * * * ?") public void TaskJob() { System.out.println("xxx");
} }

 

springMVC 定时器配置

原文:https://www.cnblogs.com/xdcr/p/8758636.html

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