- 浏览: 302423 次
- 性别:
- 来自: 北京
文章分类
最新评论
-
jakejone:
起作用了,谢谢啦
java.sql.SQLException:Value '0000-00-00' can not be represented as java.sql.Date -
BadBoyPgm:
不错 工作中刚好用到 看看知道怎么回事
ServletContextListener 应用 -
ifox:
不错哦,这个有用。找了好久呢、
struts2 iterator status index -
输入法:
上面书籍里有详细介绍?
js 获取select option 值 value text -
feihuale:
不错。。。真好,,,,学习了。。。
The error occurred while applying a parameter map.
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-2.0.xsd">
<bean id="mesBean" class="cn.xg.spring.Message" abstract="false"
lazy-init="default" autowire="default" dependency-check="default">
<property name="title">
<value>标题</value>
</property>
</bean>
<!-- spring定时器 -->
<!-- 方法一 -->
<!-- 第一步 声明一个定时任务,该类extends java.util.TimerTask -->
<bean id="clock" class="cn.xg.spring.Clock"></bean>
<!-- 第二步 调度定时任务,把声明的定时任务注入进来,并设置定时参数 -->
<bean id="scheduledClock" class="org.springframework.scheduling.timer.ScheduledTimerTask">
<property name="timerTask">
<ref bean="clock"></ref>
</property>
<property name="period">
<value>5000</value>
<!--这里是每隔多长时间就进行一次计时任务,单位ms-->
</property>
<property name="delay">
<value>5000</value>
<!--这里是服务启动后延时多少时间,开始计时任务,单位ms-->
</property>
</bean>
<!-- 启动定时任务,如果有多个定时任务,则重复步骤一,二,然后把第二步设置的beany放在下面的list列表中.此方法不能精确几点运行定时任务 -->
<bean class="org.springframework.scheduling.timer.TimerFactoryBean">
<property name="scheduledTimerTasks">
<list>
<ref bean="scheduledClock"></ref>
</list>
</property>
</bean>
<!-- 方法二 -->
<!-- 第一步 声明一个定时任务,注意不是直接声明,而是声明一个JobDetailBean,通过jobClass属性设置一个定时对象 -->
<bean id="quartzClock" class="org.springframework.scheduling.quartz.JobDetailBean">
<property name="jobClass">
<value>cn.xg.spring.QuartzClock</value>
</property>
</bean>
<!-- 第二步 调度定时任务 -->
<!--这种配置与第一种方法效果一样
<bean id="quartzClockTask" class="org.springframework.scheduling.quartz.SimpleTriggerBean">
<property name="jobDetail">
<ref bean="quartzClock"/>
</property>
<property name="startDelay">
<value>6000</value>
这里是服务启动后延时多少时间,开始计时任务,单位ms
</property>
<property name="repeatInterval">
<value>6000</value>
这里是每隔多长时间就进行一次计时任务,单位ms
</property>
</bean>
-->
<!-- 这种配置可以精确几点执行定时任务 -->
<bean id="cronQuartzClock" class="org.springframework.scheduling.quartz.CronTriggerBean">
<property name="jobDetail">
<ref bean="quartzClock"></ref>
</property>
<property name="cronExpression">
<value>0 52 22 * * ?</value><!--定时在任何月份任何日期(不管星期几)的22点52分0秒 -->
<!-- 一个cron表达式有到少6个(也可能是7个)由空格分隔的时间元素.从左到右,这些元素的定义如下:
1.秒(0-59)
2.分钟(0-59)
3.小时(0-23)
4.月份中的是期(1-31)
5.月份(1-12或SUN-DEC)
6.星期中的日期(1-7或SUN-SAT)
7.年份(1970-2099)
例子:
0 0 10,14,16 * * ? 每天上午10点,下午2点和下午4点
0 0,15,30,45 * 1-10 * ? 每月前10天每隔15分钟
30 0 0 1 1 ? 2012 在2012年1月1日午夜过30秒时
0 0 8-5 ? * MON-FRI 每个工作日的工作时间
- 区间
* 通配符
? 你不想设置那个字段
-->
</property>
</bean>
<!--第三步 启动定时任务,注意这里的ref bean -->
<bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
<property name="triggers">
<list>
<ref bean="cronQuartzClock"></ref>
</list>
</property>
</bean>
</beans>
clock.java
package cn.xg.spring;
import java.util.TimerTask;
public class Clock extends TimerTask{
@Override
public void run() {
System.out.println("clock..!clock....!.......");
}
}
QuartzClock .java
package cn.xg.spring;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.scheduling.quartz.QuartzJobBean;
public class QuartzClock extends QuartzJobBean {
@Override
protected void executeInternal(JobExecutionContext arg0)
throws JobExecutionException {
System.out.println("QuartzClock..!QuartzClock....!.......");
}
}
SpringTest .java
package cn.xg.spring;
import org.apache.log4j.Logger;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class SpringTest {
/**
* @param args
*/
public static Logger log = Logger.getLogger(SpringTest.class);
public static void main(String[] args) {
//第一种写法(加载配置文件)
ApplicationContext ctx = new
ClassPathXmlApplicationContext("applicationContext.xml");
//第二种写法
//ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("/applicationContext.xml");
//ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
//加载多个配置文件
// ApplicationContext ctx = new ClassPathXmlApplicationContext(
//new String[]{"applicationContext.xml","applicationContext2.xml"} );
}
}
所需要的jar包:
spring.jar;quartz-all-1.6.0.jar;commons-collections.jar;可能还要commons-*.jar
本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/spyking945/archive/2009/02/10/3873165.aspx
发表评论
-
struts2 redirect 参数 取不到
2009-12-03 16:07 2275关键字: struts2 redirect 参数 取不到 ... -
spring quartz 多定时任务
2009-08-17 15:31 1498<bean id="TaskAuto&qu ... -
The error occurred while applying a parameter map.
2009-08-17 11:37 20984关于“The error occurred whi ... -
用HttpSessionAttributeListener接口实现在线统计
2009-08-16 12:14 1327以下是一些不详细的代码,主要是说明原理: 捕获Sessio ... -
struts2 iterator status index
2009-08-14 17:34 11207<script type="text/ja ... -
ibatis The error occurred while applying a parameter map
2009-08-09 11:21 28386The error occurred while applyi ... -
struts2 标签截取字符串
2009-08-02 11:16 2379struts2 标签截取字符串,有点强大哦 <s:pr ... -
ibatis 双向关联不能实现
2009-08-01 11:07 1110最近用ibatis做持久层框架,好不容易吧关系给配置好了,又出 ... -
hibernate ibatis
2009-08-01 11:02 1375一。 inverse = ? ... -
struts2 selectedIndex 使用
2009-07-30 17:57 1435var ss = document.selectform ... -
struts2 类似 struts1的很低级问题
2009-07-30 15:25 1190本想通过超链接传递参数,但是网页地址栏会暴漏参数信息,于是选择 ... -
struts2 标签小体会
2009-07-30 15:16 1095<s:iterator id="m" ... -
ibatis 简单实例
2009-07-20 19:01 1580在 iBATIS SQL Maps 的世界 ... -
ibatis javaBean 书写问题
2009-07-18 15:55 1291There is no WRITEABLE property ... -
dwr spring集成
2009-07-14 18:55 2171最近用dwr做了个登陆验证的例子,可真是几经波折呀(程序很简单 ... -
spring拦截器
2009-07-02 11:31 1596今天在SSH中用到spring拦 ... -
Spring学习笔记之Bean基本管理(BeanFactory,ApplicationContext
2009-06-17 15:56 1062Spring2中: BeanFactory接口定义了6种方法 ... -
Beans, BeanFactory和ApplicationContext
2009-06-17 15:52 1061在Spring中,两个最基本 ... -
struts2.0+spring2.0+ibatis
2009-06-16 23:13 1834首页 新闻 论坛 博客 招聘 更多 ▼ 问答 知识库 ... -
http://www.ibatis.com/dtd/sql-map-2.dtd
2009-06-16 23:06 7131在做spring ibatis整合测试的时候出现如下错误 实体 ...
相关推荐
Spring定时任务的几种实现,欢迎交流!
Spring定时任务调用配置Spring定时任务调用配置Spring定时任务调用配置Spring定时任务调用配置Spring定时任务调用配置
spring定时任务SimpleTrigger 和CronTrigger 配置
spring spring spring spring定时任务所需jar 齐全
使用spring定时任务,使用spring+mybatis 向数据库中插入数据实例
一个tomcat下部署了两个应用,一个是普通web应用syncc,另一个应用syncc_wx属于微信公众号后台程序涉及消息定时推送,tomcat未分离...”spring定时任务执行两次的异常排查处理.docx"针对上述描述问题进行分析和解决。
Spring 定时任务 各参数详细说明,注解方式,简洁
Spring3.x企业应用开发实战 中 Spring 定时任务源码(spring 三种定时任务的实现方式),Spring quartz java 定时器 定时任务 源码
spring 做定时器任务时所依赖的10个jar包,用于实现java定时任务。
实现定时任务的执行操作!
NULL 博文链接:https://bijian1013.iteye.com/blog/2380233
spring 定时任务 示例代码
本文档详细介绍了Spring定时任务配置的两种方式。一种方式是使用Spring提供的 MethodInvokingJobDetailFactoryBean 代理类,Quartz通过该代理类直接调度任务类的某个函数,另外一种方式是任务类继承并实现Quartz接口...
Spring Quartz定时任务所需要的6个jar包:commons-collections.jar、commons-logging.jar、jta.jar、log4j-1.2.14.jar、quartz-all-1.6.0.jar、spring-2.0.6.jar
可运行的项目,实现了spring定时任务,很好理解!一看就懂
内含配置文件与代码示例 1.使用Quartz,这是一个功能比较强大的的调度器,可以让你的程序在指定时间执行,也可以按照某...2.Spring3.0以后自带的task,可以将它看成一个轻量级的Quartz,而且使用起来比Quartz简单许多.