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

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/30520265/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-11 09:45:20  来源:igfitidea点击:

Migrating from Spring 3 to Spring 4 - org.springframework.scheduling.quartz.CronTriggerBean

javaspringspring-mvcscheduled-tasksquartz-scheduler

提问by Sireesh Yarlagadda

I'm trying to migrate from spring 3.0.5 to spring 4.1.X .

我正在尝试从 spring 3.0.5 迁移到 spring 4.1.X 。

Spring 3 has Class named as "org.springframework.scheduling.quartz.CronTriggerBean"

Spring 3 的类名为“org.springframework.scheduling.quartz.CronTriggerBean”

But Spring 4 doesn't include this class name.

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

[5/28/15 20:10:16:798 EDT] 00000092 ClassPathXmlA W org.springframework.context.support.AbstractApplicationContext __refresh Exception encountered during context initialization - cancelling refresh attempt org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [org.springframework.scheduling.quartz.CronTriggerBean] for bean with name 'beanIdName' defined in class path resource [config/spring/WxsCacheContext.xml]; nested exception is java.lang.ClassNotFoundException: org.springframework.scheduling.quartz.CronTriggerBean at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1328)

[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;嵌套异常是 java.lang.ClassNotFoundException: org.springframework.scheduling.quartz.CronTriggerBean at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1328)

I have tried alternative like "spring-support" which has the same class. But no luck.

我尝试过类似“spring-support”的替代方案,它具有相同的类。但没有运气。

After getting that jar, it is giving errors about the quartz

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

[5/28/15 15:37:02:665 EDT] 0000006e SystemOut O ERROR (?:?) - java.lang.Exception: Bean from SpringUtils.getSpringBean(hostnameVerifierSetter) error message: Unable to initialize group definition. Group resource name [classpath*:beanRefFactory.xml], factory key [beanContext]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'beanContext' defined in URL [file:/C:/Program%20Files%20(x86)/IBM/WebSphere/AppServer/profiles/AppSrv01/installedApps/cellName/Project.ear/configurations/beanRefFactory.xml]: Bean instantiation via constructor failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.context.support.ClassPathXmlApplicationContext]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: org.quartz.impl.JobDetailImpl

[5/28/15 15:37:02:665 EDT] 0000006e SystemOut O 错误 (?:?) - java.lang.Exception: Bean from SpringUtils.getSpringBean(hostnameVerifierSetter) 错误消息:无法初始化组定义。组资源名称[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]:构造函数抛出异常;

采纳答案by Sireesh Yarlagadda

From Spring 3.1+, Change the Class names for the CronTriggerFactoryBean & JobDetailFactoryBean as like below

从 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

So your steps are:

所以你的步骤是:

Change

改变

CronTriggerBean to CronTriggerFactoryBean
JobDetailBean to JobDetailFactoryBean

CronTriggerBean 到 CronTriggerFactoryBean
JobDetailBean 到 JobDetailFactoryBean