Spring3的quartz定时任务
要使用定时任务,需要将quartz-1.5.2.jar加入lib,没有的话可以从下面地址下载:
有了这个再做个配置文件appctx-quartz.xml:
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd"> <bean id="schedulerFactory" class="org.springframework.scheduling.quartz.SchedulerFactoryBean"> <property name="triggers"> <list> <ref local="cronTriggerTest" /> </list> </property> </bean> <bean id="cronTriggerTest" class="org.springframework.scheduling.quartz.CronTriggerBean"> <property name="jobDetail" ref="jobTest" /> <property name="cronExpression"> <value>0 17 21 ? * SAT</value> <!-- FORMAT:second minute hour ? * Weekday --> </property> </bean> <bean id="jobTest" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean"> <property name="targetObject" ref="claimScheduler" /> <property name="targetMethod" value="print" /> </bean> <bean id="claimScheduler" class="com.ufo.unknown.quartz.Test"> </bean> </beans>
被调用的类如下:
package com.ufo.unknown.quartz; public class Test{ public void print(){ System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"); } }
然后在周六的21点17分0秒,Test类的print函数就被调用了,控制台输出如下:
DEBUG (JobRunShell.java:202) - Calling execute on job DEFAULT.jobTest DEBUG (CachedIntrospectionResults.java:222) - Getting BeanInfo for class [org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean$MethodInvokingJob] DEBUG (CachedIntrospectionResults.java:238) - Caching PropertyDescriptors for class [org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean$MethodInvokingJob] DEBUG (CachedIntrospectionResults.java:250) - Found bean property 'class' of type [java.lang.Class] DEBUG (CachedIntrospectionResults.java:250) - Found bean property 'methodInvoker' of type [org.springframework.util.MethodInvoker] >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Spring3的quartz定时任务的更多相关文章
- Quartz定时任务学习(二)web应用/Quartz定时任务学习(三)属性文件和jar
web中使用Quartz 1.首先在web.xml文件中加入 如下内容(根据自己情况设定) 在web.xml中添加QuartzInitializerServlet,Quartz为能够在web应用中使用 ...
- quartz定时任务框架的使用
quartz定时任务时间设置 这些星号由左到右按顺序代表 : * * * * * * * ...
- Quartz定时任务学习(二)web应用
web中使用Quartz 1.首先在web.xml文件中加入 如下内容(根据自己情况设定) 在web.xml中添加QuartzInitializerServlet,Quartz为能够在web应用中使用 ...
- Quartz定时任务使用小记(11月22日)
骤然接触quartz,先从小处着手,why,what,how quartz定时任务: 为什么使用quartz定时任务,以及定时任务在实际应用场景下的特定需求. 1.用户方面的需要,为了提供更好的使用体 ...
- quartz定时任务时间配置
quartz定时任务时间设置描述(2011-03-03 16:23:50)转载▼标签: quartz时间it 分类: 凌乱小记 这些星号由左到右按顺序代表 : * * * ...
- 对quartz定时任务的初步认识
已经好久没有写技术博文了,今天就谈一谈我前两天自学的quartz定时任务吧,我对quartz定时任务的理解,就是可以设定一个时间,然后呢,在这个时间到的时候,去执行业务逻辑,这是我的简单理解,接下来看 ...
- Spring整合Quartz定时任务执行2次,Spring定时任务执行2次
Spring整合Quartz定时任务执行2次,Spring定时任务执行2次 >>>>>>>>>>>>>>>&g ...
- Quartz 定时任务时间设置
转自https://blog.csdn.net/zdx1515888659/article/details/79158169 quartz定时任务时间设置: 这些星号由左到右按顺序代表 : * * * ...
- quartz定时任务及时间设置
quartz 定时任务时间设置1.这些星号由左到右按顺序代表 : * * * * * * * ...
随机推荐
- 平面ray trace的数据结构加速
yy了一个数据结构.. 首先考虑到,平面ray trace对应的scene是planar graph with coordinates,特点是除端点外无相交. 我们考虑对所有端点建立kd-tree,注 ...
- Lesson10 Fianl and fellings
1)Revision History Date Issue Description Author 8/May/2015 1.0 Finish the WPF of our small game,sol ...
- [LeetCode] Combinations 回溯
Given two integers n and k, return all possible combinations of k numbers out of 1 ... n. For exampl ...
- Grep查看日志的方法【转】
转自:http://blog.csdn.net/stormkey/article/details/5905204 版权声明 :转载时请以超链接形式标明文章原始出处和作者信息及本声明 http://go ...
- zabbix 批量添加聚合图形
环境为centos 脚本要在centos zabbix服务器上运行,zabbix server上运行 1.先把脚本部署到zabbix客户端,把脚本保存为nic.sh 存放路径确保zabbix可以访问 ...
- 安卓SDK安装时出现的小问题
在SDK Manager启动安装后出现网页不能访问的错误 错误日志如下 Fetching URL: https://dl-ssl.google.com/android/repository/repos ...
- UVALive 6451:Tables(模拟 Grade D)
VJ题目链接 题意:模拟输出表格 思路:模拟……很暴力 代码: #include <cstdio> #include <cstring> #include <cstdli ...
- yii2实现WebService 使用 SoapDiscovery
结合SoapDiscovery实现简单的WebService服务 1 修改php.ini文件 php_soap.dll extension=php_soap.dll 2 WebService 实现主要 ...
- AC日记——魔法少女LJJ bzoj 4399
魔法少女LJJ 思路: 动态开点权值线段树+启发式合并: 来,上代码: #include <cmath> #include <cstdio> #include <cstr ...
- linux 系统的负载与CPU、内存、硬盘、用户数监控脚本[marked]
转载文章 原始出处 在没有nagios监控的情况下,只要服务器能上互联网,就可通过发邮件的方式来提醒管理员系统资源的使用情况. 一.编写linux系统告警邮件脚本 # vim /scripts/sy ...