SpringMVC的定时任务的配置
2015-12-15 15:32
471 查看
1、在spring-mvc.xml中填写如下内容:
2、在spring-mvc.xml中填写如下内容:
xmlns:task="http://www.springframework.org/schema/task"
2、在spring-mvc.xml中填写如下内容:
http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-3.2.xsd[/code]
3、在spring-mvc.xml中填写如下内容:<context:component-scan base-package="com.bms.timing.task"/>
其中:com.bms.timing.task"是自己定义的定时任务所在的包
4、定义定时任务package com.bms.timing.task; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; @Component public class MyTask { @Scheduled(cron="0/5 * * * * ? ") //间隔5秒执行 public void taskCycle(){ System.out.println("hello world!!"); } }
其中:@Scheduled(cron="0/5 * * * * ? ") 用来设计定时任务的执行频率
5、启动任务执行结果
相关文章推荐
- JAVA标准输入--SCANNER
- JAVA关于HashMap浅谈
- Spring+SpringMVC+Mybatis 多数据源整合
- Java学习----对象的构造
- struts结合ECharts的用法
- java+selenium 截取某一元素的图片的方法
- Java中线程的同步与锁定
- 基于Struts2的文件上传
- java.util.Properties
- Java 内存回收机制介绍
- Spring常用注解
- Spring常用注解
- Spring常用注解
- Spring常用注解
- Spring多线程注入时报null异常
- java+dom4j解析xml转excel
- Spring MVC学习总结(3)——Spring3 MVC详解
- Spring3 MVC详解
- struts2 配置静态资源文件不经过strut处理(正则匹配)
- JAXB中各种常见注解小结