注解式开发spring定时器
1:spring 配置文件中增加这句
<task:annotation-driven/>
2:确保扫描程序能够扫描后 下面第3步骤的java类
<context:component-scan base-package="cms"/>
3:AnnotationQuartz.java
Java代码
/**
* User: liuwentao
* Time: 13-10-22 下午3:36
* 小说城网站欢迎访问: http://www.xiaoshuocity.com
*/
@Component
public class AnnotationQuartz {
@Scheduled(cron = "0 0/1 15,* * * ?")
//需要注意@Scheduled这个注解,它可配置多个属性:cron\fixedDelay\fixedRate
public void test() {
String dateStr = BaseDateUtil.getFormatString(new Date(), "yyyy-MM-dd HH:mm:ss");
System.out.println("小说城 www.xiaoshuocity.com 每分钟执行一次:" + dateStr);
}
}
4:spring 定时器 时间表达式解释
引用
"0 0 12 * * ?"
Fire at 12pm (noon) every day
"0 15 10 ? * *"
Fire at 10:15am every day
"0 15 10 * * ?"
Fire at 10:15am every day
"0 15 10 * * ? *"
Fire at 10:15am every day
"0 15 10 * * ? 2005"
Fire at 10:15am every day during the year 2005
"0 * 14 * * ?"
Fire every minute starting at 2pm and ending at 2:59pm, every day
"0 0/5 14 * * ?"
Fire every 5 minutes starting at 2pm and ending at 2:55pm, every day
"0 0/5 14,18 * * ?"
Fire every 5 minutes starting at 2pm and ending at 2:55pm, AND fire every 5 minutes starting at 6pm and ending at 6:55pm, every day
"0 0-5 14 * * ?"
Fire every minute starting at 2pm and ending at 2:05pm, every day
"0 10,44 14 ? 3 WED"
Fire at 2:10pm and at 2:44pm every Wednesday in the month of March.
"0 15 10 ? * MON-FRI"
Fire at 10:15am every Monday, Tuesday, Wednesday, Thursday and Friday
"0 15 10 15 * ?"
Fire at 10:15am on the 15th day of every month
"0 15 10 L * ?"
Fire at 10:15am on the last day of every month
"0 15 10 ? * 6L"
Fire at 10:15am on the last Friday of every month
"0 15 10 ? * 6L"
Fire at 10:15am on the last Friday of every month
"0 15 10 ? * 6L 2002-2005"
Fire at 10:15am on every last friday of every month during the years 2002, 2003, 2004 and 2005
"0 15 10 ? * 6#3"
Fire at 10:15am on the third Friday of every month
注解式开发spring定时器的更多相关文章
- Spring常用注解式开发
1.组件注册@Configuration.@Bean给容器中注册组件. 注解,@Configuration告诉Spring这是一个配置类,相当于bean.xml配置文件. 注解,@Bean给Sprin ...
- Spring MVC (二)注解式开发使用详解
MVC注解式开发即处理器基于注解的类开发, 对于每一个定义的处理器, 无需在xml中注册. 只需在代码中通过对类与方法的注解, 即可完成注册. 定义处理器 @Controller: 当前类为处理器 @ ...
- Spring MVC注解式开发
MVC注解式开发即处理器基于注解的类开发, 对于每一个定义的处理器, 无需在xml中注册. 只需在代码中通过对类与方法的注解, 即可完成注册. 定义处理器 @Controller: 当前类为处理器 @ ...
- 总结切面编程AOP的注解式开发和XML式开发
有段日子没有总结东西了,因为最近确实有点忙,一直在忙于hadoop集群的搭建,磕磕碰碰现在勉强算是能呼吸了,因为这都是在自己的PC上,资源确实有点紧张(搭建过程后期奉上),今天难得大家都有空(哈哈哈~ ...
- 3.2.3 SpringMVC注解式开发
SpringMVC注解式开发 1. 搭建环境 (1) 后端控制器无需实现接口 , 添加相应注解 Controller类添加注解 @Controller //该注解表将当前类交给spring容器管理 @ ...
- SpringMVC笔记:annotation注解式开发
一.配置式开发 在我们之前的学习中,springmvc使用配置式开发模式,需要在核心配置文件中springmvc.xml注册大量的bean来注入controller控制器,工作繁琐容易出错,下面我们学 ...
- shiro授权、注解式开发
在ShiroUserMapper.xml中新增内容 <select id="getRolesByUserId" resultType="java.lang.Stri ...
- shiro授权+注解式开发
shiro授权和注解式开发 1.shiro授权角色.权限 2.Shiro的注解式开发 ShiroUserMapper.xml <select id="getRolesByUserId& ...
- Shiro授权及注解式开发
目的: shiro授权 shiro注解式开发 Shiro授权 首先设计shiro权限表: 从图中我们也清晰的看出五张表之间的关系 ShiroUserMapper Set<String> g ...
随机推荐
- PHP常用库函数
1.时间和日期 如何获取时间戳 time()--从1970年开始计算的毫秒数 echo time(); 日期 echo date('Y-m-d H:i:s'); 获取默认是时区 echo date_d ...
- Git学习笔记(一)
1.git clone https://github.com/miguelgrinberg/flasky.git cd flasky git checkout 1a 2.git reset --har ...
- java 静态方法和实例方法的区别(转)
静态方法和实例方法的区别主要体现在两个方面: 在外部调用静态方法时,可以使用"类名.方法名"的方式,也可以使用"对象名.方法名"的方式.而实例方法只有后面这 ...
- java comet
http://www.javaworld.com/article/2077995/java-concurrency/asynchronous-processing-support-in-servlet ...
- Bootstrap3-技巧之解决Bootstrap模态框切换时页面抖动 or页面滚动条
Bootstrap为了让所有的页面(这里指内容溢出和不溢出)显示效果一样,采取的方法如下: 当Modal显示时,设置body -- overflow:hidden;margin-right:15px; ...
- leetcode 189
189. Rotate Array Rotate an array of n elements to the right by k steps. For example, with n = 7 and ...
- 9. js实现java方法:HtmlUtils.htmlEscape()
function htmlEscape(str) { return String(str) .replace(/&/g, '&') .replace(/"/g, '" ...
- spi can't create GMem lock
管理员身份启动cmd,输入下方命令 netsh winsock reset Successfully之后重启电脑就解决了
- web前端开发资源分享:学习计划及资料推荐
HTML & CSS W3C官网 HTML学习 CSS学习 书籍: <Head First HTML与CSS.XHTML(中文版)><CSS禅意花园(修订版)> 视频 ...
- Django URL的命令空间
为避免在模板中使用URL的硬编码,可以使用{% url %}模板标签来解决 <li><a href="/task/{{ task.id }}/">{{ ta ...