Quartz Scheduler(2.2.1) - Integration with Spring
1. maven 依赖:
<properties>
<spring.version>3.2.3.RELEASE</spring.version>
<quartz.version>2.2.1</quartz.version>
</properties> <dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>${spring.version}</version>
</dependency> <dependency>
<groupId>org.quartz-scheduler</groupId>
<artifactId>quartz</artifactId>
<version>${quartz.version}</version>
</dependency>
<dependency>
<groupId>org.quartz-scheduler</groupId>
<artifactId>quartz-jobs</artifactId>
<version>${quartz.version}</version>
</dependency> <dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.16</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.6.6</version>
<scope>provided</scope>
</dependency> <dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.1</version>
</dependency> </dependencies>
2. 定义任务类:
package com.huey.hello.quartz; import java.util.Date; import org.quartz.JobExecutionException; import com.huey.hello.quartz.utils.DateUtils; public class HelloJob { public void sayHello() throws JobExecutionException {
System.out.println("hello " + DateUtils.dateToStr(new Date()));
} }
3. Spring applicationContext.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-3.0.xsd"> <!-- 配置任务实例 -->
<bean id="helloJob" class="com.huey.hello.quartz.HelloJob" /> <!-- 配置 JobDetail -->
<bean id="myJobDetailFactory" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
<!-- 指定任务 -->
<property name="targetObject" ref="helloJob" />
<!-- 指定执行的方法 -->
<property name="targetMethod" value="sayHello" />
</bean> <!-- 配置触发器 -->
<bean id="myTriggerFactory" class="org.springframework.scheduling.quartz.CronTriggerFactoryBean">
<!-- 指定 JobDetail -->
<property name="jobDetail" ref="myJobDetailFactory" />
<!-- 指定 cron 表达式 -->
<property name="cronExpression" value="0/5 * * * * ?" />
</bean> <!-- 配置 scheduler 工厂 -->
<bean id="schedulerFactory" lazy-init="false" autowire="no" class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
<property name="triggers">
<list>
<ref bean="myTriggerFactory"/>
</list>
</property>
<!-- 是否自动启动 -->
<property name="autoStartup" value="true" />
</bean> </beans>
Quartz Scheduler(2.2.1) - Integration with Spring的更多相关文章
- 最新 Spring 4.2.2 集成 Quartz Scheduler 2.2.2 任务调度示例
参考http://blog.csdn.net/defonds/article/details/49496895 本文将演示如何通过 Spring 使用 Quartz Scheduler 进行任务调度. ...
- spring集成quartz scheduler
创建项目 有两种创建quart配置作业 1.使用MethodInvokingJobDetailFactoryBean Quartz Scheduler 配置作业(MethodInvokingJobD ...
- Table of Contents - Quartz Scheduler
Getting Started Hello World Integration with Spring Quartz Scheduler Developer Guide Usage of JobDat ...
- quartz集群分布式(并发)部署解决方案-Spring
项目中使用分布式并发部署定时任务,多台跨JVM,按照常理逻辑每个JVM的定时任务会各自运行,这样就会存在问题,多台分布式JVM机器的应用服务同时干活,一个是加重服务负担,另外一个是存在严重的逻辑问题, ...
- Quartz Scheduler(2.2.1) - hello world
简单示例 1. maven 依赖 <dependencies> <dependency> <groupId>org.quartz-scheduler</gro ...
- Quartz Scheduler(2.2.1) - Working with JobStores
About Job Stores JobStores are responsible for keeping track of all the work data you give to the sc ...
- Quartz Scheduler 开发指南(1)
Quartz Scheduler 开发指南(1) 原文地址:http://www.quartz-scheduler.org/generated/2.2.2/html/qtz-all/ 实例化调度程序( ...
- 整合shiro出现【Correct the classpath of your application so that it contains a single, compatible version of org.quartz.Scheduler】
跑的时候出现错误: Description: An attempt was made to call the method org.quartz.Scheduler.getListenerManage ...
- Sentinel Getting Started And Integration of Spring Cloud Alibaba Tutorials
原文链接:Sentinel Getting Started And Integration of Spring Cloud Alibaba Tutorials Sentinel Getting Sta ...
随机推荐
- HDU 5832 A water problem (水题,大数)
题意:给定一个大数,问你取模73 和 137是不是都是0. 析:没什么可说的,先用char 存储下来,再一位一位的算就好了. 代码如下: #pragma comment(linker, "/ ...
- 【Todo】ipcs命令学习
可以先看这一篇 http://www.jb51.net/article/40805.htm
- Weblogic安装
1.下载wls_121200.jar, 2.输入cnd打开命令提示 3.f:进入F盘 4.Java -version 验证是否配置Java环境, 5.echo %path% 查看环境变量 6.set ...
- Android---App Widget(四)
接收App Widget广播的Intent对象 AppWidgetProvider只是一个便利的类,如果你想要直接接收App Widget广播,你可以实现自己的BroadcastReceiver类或重 ...
- AJAX顺序输出
转载:http://www.cnblogs.com/niunan/archive/2010/10/13/1849873.html AJAX顺序输出 在安装大多数CMS的时候都会在安装界面上看到这样的 ...
- UVa673 Parentheses Balance
// UVa673 Parentheses Balance // 题意:输入一个包含()和[]的括号序列,判断是否合法. // 具体递归定义如下:1.空串合法:2.如果A和B都合法,则AB合法:3.如 ...
- 80端口被NT kernel & System 占用pid 4
前段时间停止了Apache,结果在打开的时候发现无法打开,80端口被占用,于是win+r 运行cmd 输入netstat -ano 可以看到80端口被PID4占用,于是打开任务管理器-进程-查看,选择 ...
- Codeforces Round #185 (Div. 2) A. Whose sentence is it? 水题
A. Whose sentence is it? Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/ ...
- Educational Codeforces Round 1 C. Nearest vectors 极角排序
Partial Tree Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/598/problem/ ...
- POJ1463:Strategic game(树形DP)
Description Bob enjoys playing computer games, especially strategic games, but sometimes he cannot f ...