MyException - 我的异常网
当前位置:我的异常网» Java Web开发 » 关于spring的quratz任务调度有关问题

关于spring的quratz任务调度有关问题(2)

www.MyException.Cn  网友分享于:2013-12-01  浏览:632次

信息:   Destroying   singletons   in   {org.springframework.beans.factory.support.DefaultListableBeanFactory   defining   beans   [testQuarz,helloworldTask,simpleTrigger,org.springframework.scheduling.quartz.SchedulerFactoryBean];   root   of   BeanFactory   hierarchy}
Exception   in   thread   "main "   org.springframework.beans.factory.CannotLoadBeanClassException:   Error   loading   class   [org.springframework.scheduling.quartz.SimpleTriggerBean]   for   bean   with   name   'simpleTrigger '   defined   in   file   [C:\Documents   and   Settings\Andy\workspace\dafasd\WebContent\WEB-INF\applicationContext.xml]:   problem   with   class   file   or   dependent   class;   nested   exception   is   java.lang.NoClassDefFoundError:   org/quartz/SimpleTrigger
Caused   by:   java.lang.NoClassDefFoundError:   org/quartz/SimpleTrigger
at   java.lang.ClassLoader.defineClass1(Native   Method)
at   java.lang.ClassLoader.defineClass(Unknown   Source)
at   java.security.SecureClassLoader.defineClass(Unknown   Source)
at   java.net.URLClassLoader.defineClass(Unknown   Source)
at   java.net.URLClassLoader.access$100(Unknown   Source)
at   java.net.URLClassLoader$1.run(Unknown   Source)
at   java.security.AccessController.doPrivileged(Native   Method)
at   java.net.URLClassLoader.findClass(Unknown   Source)
at   java.lang.ClassLoader.loadClass(Unknown   Source)
at   sun.misc.Launcher$AppClassLoader.loadClass(Unknown   Source)
at   java.lang.ClassLoader.loadClass(Unknown   Source)
at   org.springframework.util.ClassUtils.forName(ClassUtils.java:177)
at   org.springframework.beans.factory.support.AbstractBeanDefinition.resolveBeanClass(AbstractBeanDefinition.java:313)
at   org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:912)
at   org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanNamesForType(DefaultListableBeanFactory.java:165)
at   org.springframework.context.support.AbstractApplicationContext.getBeanNamesForType(AbstractApplicationContext.java:687)
at   org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:397)
at   org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:330)
at   org.springframework.context.support.FileSystemXmlApplicationContext. <init> (FileSystemXmlApplicationContext.java:89)
at   org.springframework.context.support.FileSystemXmlApplicationContext. <init> (FileSystemXmlApplicationContext.java:74)
at   org.springframework.context.support.FileSystemXmlApplicationContext. <init> (FileSystemXmlApplicationContext.java:65)
at   test.Test.main(Test.java:12)


------解决方案--------------------
要改两个地方:
1、要把quartz的类包加到classpath中,在spring的安装目录下的lib\quartz\下就有
2、applicationContext.xml文件中增加
<property name= "repeatInterval ">
<value> 1000 </value>
</property>

完整的applicationContext.xml文件如下:
<?xml version= "1.0 " encoding= "UTF-8 "?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN " "http://www.springframework.org/dtd/spring-beans.dtd ">
<beans>
<bean id= "testQuarz " class= "test.TestQuarz " />
<bean id= "helloworldTask " class= "org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean ">

文章评论

软件开发程序错误异常ExceptionCopyright © 2009-2015 MyException 版权所有