- 浏览: 923479 次
- 性别:
- 来自: 广州
文章分类
- 全部博客 (229)
- spring (20)
- myBatis (1)
- javase (31)
- 设计模式 (1)
- jQuery EasyUI (4)
- 编程工具 (8)
- Hibernate (3)
- tomcat (3)
- js (27)
- Jboss (2)
- dom4j (1)
- 操作系统 (5)
- 数据库 (26)
- springmvc (6)
- 程序人生 (5)
- JDBC (1)
- android (6)
- groovy (2)
- memcached (11)
- Nginx (8)
- maven (7)
- javaEE (13)
- jquery (3)
- linux (4)
- 单元测试 (6)
- 算法 (6)
- resin 服务器 (5)
- 缓存 (8)
- slf4j日志 (1)
- resin 服务器;log4j (2)
- 性能调休 (25)
- 网络编程 (10)
- 多线程 (9)
- json (1)
最新评论
-
lliiqiang:
主要原因还是因为html格式太复杂多变了。很难过滤所有的危险代 ...
java 防止xss攻击 -
u011670948:
Mustache模板遍历输出数据 -
u011670948:
Mustache模板遍历输出数据 -
masuweng:
spring @Autowire 的注解默认是按类型注入bean -
masuweng:
spring @Autowire 的注解默认是按类型注入bean
from《Spring in Action3》
基于注解的sping3定时器配置
1.首先要在application-context.xml里面配置好namespace 和schema,如下:
xmlns:task="http://www.springframework.org/schema/task"
http://www.springframework.org/schema/task
http://www.springframework.org/schema/task/spring-task-3.0.xsd
2.在application-context.xml里面配置<task:annotation-driven/>,加下面一行就行:
<task:annotation-driven/>
<!-- The <task:annotation-driven/> element sets Spring up to automatically support
scheduled and asynchronous methods. These methods are identified with the
@Scheduled and @Async methods, respectively -->
3.在Bean里面的调度方法加注解@Scheduled,其中@Scheduled的attribute有三种:
(1)fixedRate:每隔多少毫秒执行一次该方法。如:
@Scheduled(fixedRate=2000) public void scheduleMethod(){ System.out.println("Hello world..."); }
(2)fixedDelay:当一次方法执行完毕之后,延迟多少毫秒再执行该方法。
(3)cron:详细配置了该方法在什么时候执行。cron值是一个cron表达式。如:
@Scheduled(cron="0 0 0 * * SAT") public voidarchiveOldSpittles(){ // ... }
The value given to the cron attribute is a Cron expression. For those who aren’t so
well-versed in Cron expressions, let’s break down the cron attribute. The Cron expres-
sion is made up of six (or possibly seven) time elements, separated by spaces. In order
from left to right, the elements are defined as follows:
1 Seconds (0-59)
2 Minutes (0-59)
3 Hours (0-23)
4 Day of month (1-31)
5 Month (1-12 or JAN-DEC)
6 Day of week (1-7 or SUN-SAT)
7 Year (1970-2099)
一些cron表达式的例子:
Cron expression What it means
0 0 10,14,16 * * ? Every day at 10 a.m., 2 p.m., and 4 p.m.
0 0,15,30,45 * 1-30 * ? Every 15 minutes on the first 30 days of the month
30 0 0 1 1 ? 2012 30 seconds after midnight on January 1, 2012
0 0 8-17 ? * MON-FRI Every working hour of every business day
详细参考Spring reference document.
发表评论
-
spring boot 2.0.1版本,多数据源支持
2018-05-12 09:30 1571有时候我们需要在程序中加载多个数据源,用spring jp ... -
eureka的Instances status列表显示ip
2017-09-16 14:42 16140spring cloud 版本 Dalston.R ... -
[转]解惑 spring 嵌套事务
2017-02-08 19:36 757转:http://www.iteye.com/topic/35 ... -
spring autowire="byName" 注入属性
2016-01-30 12:03 2407byName 根据属性名自动装配。此选项将检查容器并根据名 ... -
springJdbc 插入数据返回主键
2015-11-24 16:22 908public long addMsg(final SysMe ... -
RequestMappingHandlerMapping的用法
2014-11-26 14:43 30801有时候,想查看应用请求对应的ur和方法l情况,可以用Req ... -
Spring MVC HandlerExceptionResolver自定义处理异常
2014-10-29 11:27 3752用spring的接口HandlerExceptionReso ... -
spring @Autowire 的注解默认是按类型注入bean
2014-04-24 14:30 10013spring @Autowire 的注解默认是按类型注入b ... -
spring结合mysql事务注解@Transactional不起作用的问题
2014-04-23 18:04 24264最近遇到的一个比较诡异的问题,貌似各种配置都正确了,事务不 ... -
SpringMVC中使用Interceptor拦截器[转]
2014-04-18 15:30 2196转:http://haohaoxuexi.iteye.com ... -
spring抛异常之后的事务回滚
2014-03-28 15:12 1841spring 的声明式事务注 ... -
Spring MVC防御CSRF、XSS和SQL注入攻击[转]
2014-02-13 13:53 1687转;http://www.cnblogs.com/Mainz ... -
maven单元测试报java.lang.IllegalStateException: Failed to load ApplicationContext
2013-12-20 15:35 104432报这个异常java.lang.IllegalState ... -
spring 中运用单元测试
2013-12-17 11:47 979直接上代码 package cn.pconline.bb ... -
spring 用静态工厂方法初始化bean的注意事项
2013-12-16 17:48 3929如下 <bean id="sockIOP ... -
Java EE6中的新框架 Bean的验证
2012-09-14 17:06 4090转:http://xiangtui.iteye.com/blo ... -
Spring中ApplicationContext加载机制
2012-09-13 20:41 2108转:http://blog.csdn.net/edis ... -
创建bean失败会造成创建sessionFactory报空指针异常
2012-09-12 18:05 7Caused by: org.springframework. ... -
Spring MVC学习之三:处理方法返回值的可选类型
2012-08-07 11:36 1326转:http://flyer2010.iteye.com/bl ... -
【转】spring配置datasource三种方式
2011-12-31 17:42 13801,使用org.springframework.jdbc.da ...
相关推荐
Spring3.0 mvc 定时器及多线程任务demo
通过总结师兄师姐的例子以及前人的经验,总结出spring的项目实例,其中包含3.0之前和3.0之后的spring版本,分别以2.5.6版本和3.0.1版本为例,给出了项目实例,方便大家学习交流。
通过系统的查找spring定时器的相关文档,查找了2.5.6版本和3.0.1版本的区别,总结归纳出学习文档,以及做出相应的项目实例,方便大家学习交流。对不同的版本都能够适应学习。
【源码】mysql版本_spring3.0 系统模块 1. 组织管理:角色管理,分角色组和成员,有组权限和成员权限。 2. 系统用户:对各个基本的组会员增删改查,单发、群发邮件短信,导入导出excel表格,批量删除 3. 会员管理:...
【源码】oracle版本_spring3.0 系统模块 1. 组织管理:角色管理,分角色组和成员,有组权限和成员权限。 2. 系统用户:对各个基本的组会员增删改查,单发、群发邮件短信,导入导出excel表格,批量删除 3. 会员管理:...
pring定时器的使用,spring3.0确实是要简单好多,不过很多项目都还没有升级到spring3.0所以对于2.5的配置也需要了解。
定时器集成包,spring3.0+quartz1.0,http://blog.csdn.net/dzy21
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd"> ...
4.“定时器.txt”记录的是长链接链路检查的基于spring的配置,如果使用java原生定时器可自行配置。 5.依赖包包括log4j.jar、quartz-1.5.2.jar,quartz-1.5.2.jar为定时器使用,除此之外无特殊依赖包
定时器:Quartz 数据库连接池:Druid 页面交互:layuiAdmin 验证框架:hibernate-Validation 接口文档:Swagger 环境需求 JDK >= 1.8 MySQL >= 5.7 Maven >= 3.0 使用说明 1.控制层接口版本管理、包装响应Result...
- 定时器:Quartz 2.3 - 数据库连接池:Druid 1.0 - 日志管理:SLF4J 1.7、Log4j - 页面交互:Vue2.x - 缓存:redis 2.8 - 手机页面:weui 软件需求** - JDK1.8+ - MySQL5.5+ - Tomcat7.0+ - Maven3.0+ **本地...
- 定时器:Quartz 2.3 - 数据库连接池:Druid 1.1 - 日志管理:SLF4J 1.7、Log4j - 页面交互:Vue2.x **软件需求** - JDK1.8 - MySQL5.5+ - Maven3.0+ **本地部署** - 通过git下载源码 - 创建...