从Spring 3迁移到Spring 4 - org.springframework.scheduling.quartz.CronTriggerBean

Sir*_*dda 28 java spring spring-mvc scheduled-tasks quartz-scheduler

我正试图从春季3.0.5迁移到4.1.X春季.

Spring 3的Class命名为"org.springframework.scheduling.quartz.CronTriggerBean"

但是Spring 4不包含这个类名.

[5/28/15 20:10:16:798 EDT] 00000092 ClassPathXmlA W org.springframework.context.support.AbstractApplicationContext __refresh在上下文初始化期间遇到异常 - 取消刷新尝试org.springframework.beans.factory.CannotLoadBeanClassException:找不到类[org.springframework.scheduling.quartz.CronTriggerBean]用于在类路径资源[config/spring/WxsCacheContext.xml]中定义的名称为'beanIdName'的bean; 嵌套异常是org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1328)中的java.lang.ClassNotFoundException:org.springframework.scheduling.quartz.CronTriggerBean

我尝试了类似"弹簧支持"的替代方案,它具有相同的类别.但没有运气.

得到那个罐子之后,它给出了关于石英的错误

[5/28/15 15:37:02:665 EDT] 0000006e SystemOut O ERROR(?:?) - java.lang.Exception:SpringUtils.getSpringBean(hostnameVerifierSetter)中的Bean错误消息:无法初始化组定义.组资源名称[classpath*:beanRefFactory.xml],工厂密钥[beanContext]; 嵌套异常是org.springframework.beans.factory.BeanCreationException:在URL [file:/ C:/ Program%20Files%20(x86)/ IBM/WebSphere/AppServer/profiles/AppSrv01 /中定义的名称为'beanContext'的bean创建错误installedApps/cellName/Project.ear/configurations/beanRefFactory.xml]:构造函数的Bean实例化失败; 嵌套异常是org.springframework.beans.BeanInstantiationException:无法实例化[org.springframework.context.support.ClassPathXmlApplicationContext]:构造函数抛出异常; 嵌套异常是java.lang.NoClassDefFoundError:org.quartz.impl.JobDetailImpl

Sir*_*dda 54

从Spring 3.1+开始,更改CronTriggerFactoryBean和JobDetailFactoryBean的类名,如下所示

   org.springframework.scheduling.quartz.CronTriggerBean 
                               org.springframework.scheduling.quartz.CronTriggerFactoryBean
   org.springframework.scheduling.quartz.JobDetailBean
                               org.springframework.scheduling.quartz.JobDetailFactoryBean
Run Code Online (Sandbox Code Playgroud)

所以你的步骤是:

更改

CronTriggerBean到CronTriggerFactoryBean
JobDetailBean到JobDetailFactoryBean

  • 和`org.springframework.scheduling.quartz.SimpleTriggerBean`成为`org.springframework.scheduling.quartz.SimpleTriggerFactoryBean` (6认同)