applicationContext-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"
xmlns:jee="http://www.springframework.org/schema/jee" xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.5.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd"
default-lazy-init="false">
<!-- task -->
<!-- 定义了一个任务 -->
<bean id="quartzClock" class="org.springframework.scheduling.quartz.JobDetailBean">
<property name="jobClass">
<value>mrd.shcreating.task.TaskServer</value><!-- 类的名字 有这个类完成具体的 任务 -->
</property>
</bean>
<!-- 第二步 调度定时任务 -->
<!--这种配置与第一种方法效果一样 -->
<bean id="quartzClockTask" class="org.springframework.scheduling.quartz.SimpleTriggerBean">
<property name="jobDetail">
<ref bean="quartzClock"/>
</property>
<property name="startDelay"><!-- 这里是服务启动后延时多少时间,开始计时任务,单位ms -->
<value>6000</value>
</property>
<property name="repeatInterval"><!-- 这里是每隔多长时间就进行一次计时任务,单位ms -->
<value>2000</value>
</property>
</bean>
<!-- 这种配置可以精确几点执行定时任务 -->
<!-- 定义了任务的执行方式 -->
<bean id="cronQuartzClock" class="org.springframework.scheduling.quartz.CronTriggerBean" >
<property name="jobDetail">
<ref bean="quartzClock"></ref>
</property>
<property name="cronExpression">
<value>3 * * * * ?</value>
</property>
</bean>
<!--第三步 启动定时任务,注意这里的ref bean -->
<bean id="schedulerFactoryBean" class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
<property name="triggers">
<list>
<ref bean="cronQuartzClock"></ref>
</list>
</property>
</bean>
</beans>
//@Component
public class TaskServer extends QuartzJobBean{
// public TaskServer() {
// super();
// System.out.println("每次都创建一个新对象 任务开始");
// }
@Override
protected void executeInternal(JobExecutionContext arg0)
throws JobExecutionException {
// System.out.println("执行定时任务..!"+String.format("%1$tF %1$tT" ,new Date()));
}
}
分享到:
相关推荐
Spring2.5+Quartz定时任务简单例子web工程 myeclipse 项目开发的,可直接导入运行
当然你可以采用其它的一些工具来设法令整个应用包变小,节省空间的重点在于准确地找出自己所需的Spring依赖类,然后合并所需的类与包就可以了。Eclispe有个插件叫 ClassPath Helper可以帮你找找所依赖的类。 Spring...
spring+quartz定时小例子,架包+文档 我自己整理的
好像很多人整合出现了问题,所以抽个demo出来 是一个demo包含源码和lib 在tomcat下可以执行
springtask 和 quartz +ssh简单示例springtask 和 quartz +ssh简单示例springtask 和 quartz +ssh简单示例springtask 和 quartz +ssh简单示例
spring之quartz例子,与oracle整合,不过spring中的MethodInvokingJobDetailFactoryBean方法在存数据库时序列化有bug,在本例子中,使用了修复后的MethodInvokingJobDetailFactoryBean方法,避免了因序列化而报错。
spring3整合quartz1.8和spring3整合quartz2.2两个版本示例
spring3.1 与 quartz 1.8.6 整合 的 所有jar
spring2.0 使用 Quartz 必备包 里面有: quartz-all-1.5.2.jar spring-support.jar 适合:SSH框架 spring2.0 strut2.0 hibernate3.2等
Java_Spring与Quartz的整合
一个spring quartz的定时任务,放到tomcat下就可以看到后台打印了
刘冬编写Spring.NET学习笔记25——整合Quartz.NET例子。 原文: http://www.cnblogs.com/GoodHelper/archive/2009/11/20/SpringNet_QuartzNet.html
基于struts2 spring2.5 hibernate3的人事管理系统 源码完整包 ..系统采用了贫血模式实现dao
在网上扒拉下来的spring3和quartz1.8.6版本集成的代码,貌似spring4和quartz1.8.6就集成不了了,得升到quartz 2.x
NULL 博文链接:https://newbutton.iteye.com/blog/652964
Spring中的Quartz配置-Spring-定时器-java定时器.doc
本项目来源与网络,本人对项目...直接通过mvn 倒入项目,在Spring-quartz-demo\src\main\webapp\sql 有sql 建立数据库,表 启动tomcat 直接访问http://localhost:8080/Spring-quartz-demo/task/taskList.htm 就可以使用
spring3 配置quartz定时任务的使用。一个小例子。可直接运行Test.java。就可以启动定时任务。每10秒钟执行一次,可以根据自己配置。
Spring集成的Quartz例子
关于spring中quartz的配置