Spring2.5 定时器 错误 org.springframework.scheduling.quartz.SchedulerFactoryBean#0
2013-12-19 11:55
302 查看
Spring2.5 定时器 错误 记录一下
一、 开发环境 MyEclipse6.5 、jdk1.5 、J2EE5
二、 使用技术 struts2 、hibernate、 Spring2.5
(1)、发生问题:严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.scheduling.quartz.SchedulerFactoryBean#0' defined in class path resource [scheduler.xml]: Cannot resolve reference
to bean 'cronTriggerBean' while setting bean property 'triggers' with key [0]; nested exception is org.springframework.beans.factory.CannotLoadBeanClassException: Error loading class [org.springframework.scheduling.quartz.CronTriggerBean] for bean with name
'cronTriggerBean' defined in class path resource [scheduler.xml]: problem with class file or dependent class; nested exception is java.lang.IncompatibleClassChangeError: class org.springframework.scheduling.quartz.CronTriggerBean has interface org.quartz.CronTrigger
as super class
看到这个错误大概意思,应该是指Spring 在创建这个工厂时发生了错误 class org.springframework.scheduling.quartz.CronTriggerBean
, 好像说是需要继承一个超类,
上网查了一下,spring定时器,有2种配置方法,1是继承超类,2是通过配置。
另外,看到其他人工程下比我多一个 quartz-1.5.2.jar,加到工程中,错误解决。
我是写的xml配置,第1种我没试,所以只介绍第2种,以下是我的配置
1、
2、mytimer.xml
3、我的实现类
cn.com.common.listener.SpringTimer
4、启动tomcat ,看到实现类效果
一、 开发环境 MyEclipse6.5 、jdk1.5 、J2EE5
二、 使用技术 struts2 、hibernate、 Spring2.5
(1)、发生问题:严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.scheduling.quartz.SchedulerFactoryBean#0' defined in class path resource [scheduler.xml]: Cannot resolve reference
to bean 'cronTriggerBean' while setting bean property 'triggers' with key [0]; nested exception is org.springframework.beans.factory.CannotLoadBeanClassException: Error loading class [org.springframework.scheduling.quartz.CronTriggerBean] for bean with name
'cronTriggerBean' defined in class path resource [scheduler.xml]: problem with class file or dependent class; nested exception is java.lang.IncompatibleClassChangeError: class org.springframework.scheduling.quartz.CronTriggerBean has interface org.quartz.CronTrigger
as super class
看到这个错误大概意思,应该是指Spring 在创建这个工厂时发生了错误 class org.springframework.scheduling.quartz.CronTriggerBean
, 好像说是需要继承一个超类,
上网查了一下,spring定时器,有2种配置方法,1是继承超类,2是通过配置。
另外,看到其他人工程下比我多一个 quartz-1.5.2.jar,加到工程中,错误解决。
我是写的xml配置,第1种我没试,所以只介绍第2种,以下是我的配置
1、
<?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:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd"> <!-- 在spring文件中引入定时器配置文件 --> <!-- 定时器 --> <import resource="classpath:mytimer.xml"/> </beans>
2、mytimer.xml
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN" "http://www.springframework.org/dtd/spring-beans-2.0.dtd"> <beans> <!-- 定时扫描周期,如果已到期,则结束周期 --> <!-- 定时服务定义 --> <bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean"> <!-- 自动启动 --> <property name="autoStartup"> <value>true</value> </property> <property name="triggers"> <list> <ref bean="cronTriggerBean" /> </list> </property> </bean> <bean id="cronTriggerBean" class="org.springframework.scheduling.quartz.CronTriggerBean"> <property name="jobDetail"> <ref bean="jobDetailBean" /> </property> <property name="cronExpression"> <!-- 过一秒开始,每间隔两秒执行--> <value>1/2 * * * * ?</value> </property> </bean> <bean id="jobDetailBean" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean"> <property name="targetObject" ref="springTimer"></property> <property name="targetMethod" value="tiggertimer"></property> <property name="concurrent" value="false" /> </bean> <bean id="springTimer" class="cn.com.common.listener.SpringTimer"></bean> </beans>
3、我的实现类
cn.com.common.listener.SpringTimer
package cn.com.common.listener; import java.util.Date; public class SpringTimer { public void tiggertimer(){ System.out.println(new Date()); } }
4、启动tomcat ,看到实现类效果
相关文章推荐
- spring3.2 定时器 SchedulerFactoryBean 注入错误
- 集成Spring 2.5并整合JPA常见错误
- 集成Spring 2.5并整合JPA常见错误
- dubbo2.5-spring4-mybastis3.2-springmvc4-mongodb3.4-redis3.2整合(九)之 spring中定时器quartz的整合
- dubbo2.5-spring4-mybastis3.2-springmvc4-mongodb3.4-redis3.2整合(十一)之 spring中定时器quartz的整合续集(Quartz集群配置)
- 最近用hibernate3+spring2.5+freemarker2.4做了一个案例出现错误!
- java开源框架集成常见错误之spring2.5中没有org.springframework.web.struts.DelegatingActionProxy ,使得Action不能注入到spring中
- 在spring框架中配置Quartz定时器发生错误: class org.springframework.scheduling.quartz.JobDetailBean has interface org.quartz.JobDetail as sup
- struts2.1+spring2.5+hibernate3框架搭建时出现的错误及解决办法
- Windows下编译Spring-framework.5.0.0.BUILD-SNAPSHOT编译错误记录
- SpringMVC @ResponseBody 415错误处理
- Spring2.5整合ActiveMQ 5.2(P2P文本消息)
- 传智播客-spring2.5(1)-IoC与bean的实例化、轻量级和重量级之分
- SSH(struts 1.x+spring 2.5+hibernate 3.2)开发文件配置
- 使用Spring2.5的Autowired实现注释型的IOC
- spring配置定时器
- springboot错误 java.lang.IllegalArgumentException:No converter found for return value of type
- Spring整合Quartz实现动态定时器
- Spring Boot+Shiro+Redis(redisson)整合时,采用内嵌tomcat启动错误原因分析
- spring的定时器