spring2.5.6下配置定时器
来源:互联网 发布:怎么通过网络找客户 编辑:程序博客网 时间:2024/05/21 11:17
applicationContext.xml 代码如下:
<?xml version="1.0"encoding="UTF-8"?>
<beansxmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context"xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beanshttp://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/aop
http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-2.5.xsd">
<!-- 支持元注释 -->
<context:annotation-config />
<!-- 扫描包目录 -->
<context:component-scanbase-package="com"></context:component-scan>
<importresource="scheduler.xml"/>
</beans>
scheduler.xml:代码如下:
<?xml version="1.0" encoding="GBK"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN""http://www.springframework.org/dtd/spring-beans-2.0.dtd">
<beans>
<!-- 定时扫描周期,如果已到期,则结束周期 -->
<!-- 定时服务定义 -->
<beanclass="org.springframework.scheduling.quartz.SchedulerFactoryBean">
<!-- 自动启动 -->
<propertyname="autoStartup">
<value>true</value>
</property>
<propertyname="triggers">
<list>
<reflocal="testTrigger"/>
</list>
</property>
</bean>
<beanid="testTrigger"class="org.springframework.scheduling.quartz.CronTriggerBean">
<propertyname="jobDetail">
<refbean="testJobDetail"/>
</property>
<propertyname="cronExpression">
<!-- 过一秒开始,每间隔两秒执行-->
<value>1/2 ** * * ?</value>
</property>
</bean>
<beanid="testJobDetail"class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
<propertyname="targetObject">
<refbean="testJob"/>
</property>
<propertyname="targetMethod">
<value>test</value>
</property>
<propertyname="concurrent" value="false"/>
</bean>
<beanid="testJob"class="com.jungle.TestJob"></bean>
</beans>
TestJob类:代码如下:
package com.jungle;
public class TestJob {
public void test() {
System.out.println("test!!!");//运行效果是每间隔两秒打印这句话一次。
}
}
<dependency>
<groupId>quartz-all</groupId>
<artifactId>quartz-all</artifactId>
<version>1.6.1</version>
</dependency>
jar包下载: http://download.csdn.net/detail/shiyuezhong/4553072
- spring2.5.6下配置定时器
- Spring2.5.6定时器的使用
- spring定时器的使用(spring2.5.6)
- spring定时器的使用(spring2.5.6)
- Spring2.5.6 配置ehcache1.5.
- Spring2.5.6中applicationContext.xml配置
- spring2.0 aop配置
- Spring2 quartz 配置
- hibernate3+spring2集成配置
- spring2.0_aop配置
- spring2.5 基本配置
- spring2.5 配置Perf4J
- spring2.0 事务配置
- spring2的事物配置
- Spring2.5常用配置
- spring2.5+ 配置事务
- Spring2.5.5常用配置
- ssh配置(struts2.1.6+spring2.5.6+hibernate3.3.2)
- dom解析xml
- 家庭理财 数据库的设计
- 第八章 复杂数据类型与指针
- Net类型设计准则
- POJ 3125 Printer Queue(打印队列---模拟)
- spring2.5.6下配置定时器
- poj1579 Function Run Fun
- POJ 1840 Eqs(简单hash入门)
- ORC 2V2 详细心得
- 第10章 网络编程 08_总结
- WWDC 2012 Session 221 iOS User Interface Design (iOS 用户界面设计)
- QML范例详解
- 再读《The C Programming Language》 - 第一章 1.6 数组
- OJ上关于阶乘位数的公式