注解式开发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 ...
随机推荐
- <页面里折合与打开>
主要思想是:通过覆盖,显示的方式.visible 为 true与false,id以及function函数中参数的不同. 具体代码如下: <script type="text/javas ...
- SQLSERVER分页查询
转:http://blog.csdn.net/qiaqia609/article/details/41445233 Sqlserver数据库分页查询一直是Sqlserver的短板, 第一种方案 ...
- android sdk manager 代理设置(送给牛逼的)
解决android sdk更新慢的问题(公司竟然把sdk更新给墙了). 第一步:如下图 第二部:进入代理设置页面,进行设置.如下图
- 外壳exe通过反射调用dll时
外壳exe通过反射调用dll时,dll是 4.0的框架,外壳exe也需要编译成4.0的框架,如果dll本身有调用32位的dll,那么外壳exe也需要编译成32位. 调试时报的那个错,直接继续运行,不影 ...
- Android自动化学习笔记之Robotium:学习官网实例
---------------------------------------------------------------------------------------------------- ...
- jira的使用
http://www.cnblogs.com/yangxia-test/p/4448002.html linux下的安装: http://blog.csdn.net/crave_shy/article ...
- 14,SFDC 管理员篇 - 外部数据集成
1,Connect an External Data Source, 添加新的数据源,填写如下 2, 点击Validate and Sync 按钮 3,添加Orders和Orders Details ...
- Web 开发人员系统重装备忘录
准备工作: 一.配置IIS 软件安装: 一.大块头: 1.VS2005 1.VS2005SP1 2.VSS 2005 2.VS2008 1.VS2008TeamExplorer 2.VS2008SP1 ...
- Spring boot开发过程遇到的一些小问题
1.无法将yml文件自动注入到对应的类的实例中去: pom.xml文件里没有加如下依赖 <dependency> <groupId>org.springframework.bo ...
- Eclipse 4.2 (Juno) 'Cannot create a server using the selected type' in Tomcat 7 - Stack Overflow.html
[太神奇了,真的可以呀] 原文:http://stackoverflow.com/questions/13423593/eclipse-4-2-juno-cannot-create-a-server- ...