Caused by: java.lang.ClassNotFoundException: org.springframework.scheduling.quartz.CronTriggerBean

在ssh框架中配置quartz定时器出现:

  1. Caused by: java.lang.ClassNotFoundException: org.springframework.scheduling.quartz.CronTriggerBean
  2.     at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
  3.     at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
  4.     at java.security.AccessController.doPrivileged(Native Method)
  5.     at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
  6.     at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
  7.     at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
  8.     at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
  9.     at org.springframework.util.ClassUtils.forName(ClassUtils.java:250)
  10.     at org.springframework.beans.factory.support.AbstractBeanDefinition.resolveBeanClass(AbstractBeanDefinition.java:401)
  11.     at org.springframework.beans.factory.support.AbstractBeanFactory.doResolveBeanClass(AbstractBeanFactory.java:1432)
  12.     at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1377)
  13.     ... 25 more

实际上是因为quartz的配置信息用的是旧版本、而依赖的确是高版本的jar包

在quartz 1.8.6及以前版本的时候 调度触发器 依赖的类是 org.springframework.scheduling.quartz.CronTriggerBean

在2.xx版本之后就改为了org.springframework.scheduling.quartz.CronTriggerFactoryBean

因此当你依赖2.x.x版本之后只需将调度触发器的依赖类改为 org.springframework.scheduling.quartz.CronTriggerFactoryBean即可

在这贴出我quartz.xml的配置文件,供大家参考:

    1. <beans xmlns="http://www.springframework.org/schema/beans"
    2. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    3. xmlns:mvc="http://www.springframework.org/schema/mvc"
    4. xmlns:context="http://www.springframework.org/schema/context"
    5. xmlns:aop="http://www.springframework.org/schema/aop"
    6. xmlns:tx="http://www.springframework.org/schema/tx"
    7. xmlns:mybatis="http://mybatis.org/schema/mybatis-spring"
    8. xsi:schemaLocation="http://www.springframework.org/schema/beans
    9. http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
    10. http://www.springframework.org/schema/mvc
    11. http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd
    12. http://mybatis.org/schema/mybatis-spring
    13. http://mybatis.org/schema/mybatis-spring.xsd
    14. http://www.springframework.org/schema/context
    15. http://www.springframework.org/schema/context/spring-context-3.2.xsd
    16. http://www.springframework.org/schema/aop
    17. http://www.springframework.org/schema/aop/spring-aop-3.2.xsd
    18. http://www.springframework.org/schema/tx
    19. http://www.springframework.org/schema/tx/spring-tx-3.2.xsd ">
    20.  
    21. <bean id="quartzJob" class="com.ahxh.quartz.QuartzJob"></bean>
    22.  
    23. <!-- 使用MethodInvokingJobDetailFactoryBean,任务类可以不实现Job借口,通过targetMethod指定调用方法 -->
    24. <bean id="JobTask" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
    25. <!-- 要调度的对象 -->
    26. <property name="targetObject" ref="quartzJob" />
    27. <!-- 要执行的方法名称 -->
    28. <property name="targetMethod" value="excutor" />
    29. <!-- 将并发设置为false -->
    30. <property name="concurrent" value="false"></property>
    31. </bean>
    32. <!-- 调度触发器 -->
    33. <bean id="trigger" class="org.springframework.scheduling.quartz.CronTriggerFactoryBean">
    34. <property name="jobDetail" ref="JobTask" />
    35. <!-- 表达式 -->
    36. <property name="cronExpression" value="${qzExcutTimer}" />
    37. </bean>
    38. <!-- 调度工厂:如果将lazy-init="false",那么容器启动就会执行调度程序 -->
    39. <bean id="startQuartz" lazy-init="false" autowire="no" class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
    40. <property name="triggers">
    41. <list>
    42. <!-- 作业调度器,list下可加入其它的调度器 -->
    43. <ref bean="trigger" />
    44. </list>
    45. </property>
    46. </bean>
    47.  
    48. </beans>

原文地址:https://www.cnblogs.com/qianzf/p/12354412.html

时间: 2024-11-22 21:18:13

Caused by: java.lang.ClassNotFoundException: org.springframework.scheduling.quartz.CronTriggerBean的相关文章

maven项目出现:Caused by: java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener

今天安装和部署maven项目的时候一直都出现这样的错误:  maven项目出现:Caused by: java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener  按照网上的好多都是说spring.jar包什么的问题,但是我这个项目修改了也没有效果的样子,后来自己尝试了一下,发现是maven的包没成功导入项目中: 在eclipse中:如果在这样:右击 Maven project -

【异常】Caused by: java.lang.ClassNotFoundException: org.springframework.dao.DataIntegrityViolationException

Caused by: java.lang.ClassNotFoundException: org.springframework.dao.DataIntegrityViolationException at java.net.URLClassLoader$1.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(U

Caused by: java.lang.ClassNotFoundException: org.springframework.orm.hibernate4.HibernateTemplate

1.错误描述 严重: Context initialization failed org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [org.springframework.orm.hibernate4.HibernateTemplate] for bean with name 'hibernateTemplate' defined in ServletContext resourc

Caused by: java.lang.ClassNotFoundException: org.springframework.expression.ExpressionParser

1.错误描述 usage: java org.apache.catalina.startup.Catalina [ -config {pathname} ] [ -nonaming ] { -help | start | stop } 2014-7-12 0:44:33 org.apache.catalina.core.AprLifecycleListener init 信息: Loaded APR based Apache Tomcat Native library 1.1.29 using

Caused by: java.lang.ClassNotFoundException: org.springframework.context.ApplicationContextAware

1.错误描述 usage: java org.apache.catalina.startup.Catalina [ -config {pathname} ] [ -nonaming ] { -help | start | stop } 2014-7-12 0:25:53 org.apache.catalina.core.AprLifecycleListener init 信息: Loaded APR based Apache Tomcat Native library 1.1.29 using

Caused by: java.lang.ClassNotFoundException: org.springframework.web.socket.server.standard.ServerEndpointExporter

Exception in thread "main" java.lang.NoClassDefFoundError: org/springframework/web/socket/server/standard/ServerEndpointExporter    at java.lang.Class.getDeclaredMethods0(Native Method)    at java.lang.Class.privateGetDeclaredMethods(Class.java:

idea 中 Caused by: java.lang.ClassNotFoundException: org.springframework.web.util.IntrospectorCleanupListener

idea  中 Caused by: java.lang.ClassNotFoundException: org.springframework.web.util.IntrospectorCleanupListener 项目启动出现未知错误: 代码未错,即为idea配置问题: 解決 在IDEA中点击File > Project Structure > Artifacts > 在右侧Output Layout右击项目名,选择Put into Output Root. ?执行后,在WEB-I

Caused by: java.lang.ClassNotFoundException: org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter

严重: StandardWrapper.Throwableorg.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping': Invocation of init method failed; nested excepti

Caused by: java.lang.ClassNotFoundException: org.springframework.integration.handler.support.HandlerMethodArgumentResolversHolder

<dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-stream</artifactId> <version>RELEASE</version></dependency> 将pom中这个干掉就行了,暂时没搞清楚为啥 原文地址:https://www.cnblogs.com/guokejiang/p/