gpt4 book ai didi

java - 嵌套异常是 org.springframework.beans.TypeMismatchException :

转载 作者:行者123 更新时间:2023-12-02 13:37:07 29 4
gpt4 key购买 nike

我是 Quartz 的新手,我刚刚开始一个已经使用 Quartz 调度程序的项目。该项目正在编译,但在运行时抛出以下异常:

BeanCreationException: Error creating bean with name 'galleryBulkTrigger' defined in ServletContext resource [/WEB-INF/spring/applicationContext-scheduler.xml]: Cannot resolve reference to bean 'galleryBulkJob' while setting bean property 'jobDetail'; nested exception is


org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'galleryBulkJob' defined in ServletContext resource [/WEB-INF/spring/applicationContext-scheduler.xml]: Initialization of bean failed; nested exception is org.springframework.beans.TypeMismatchException: Failed to convert property value of type 'java.lang.String' to required
type 'java.lang.Class' for property 'jobClass'; nested exception is java.lang.IllegalArgumentException: Cannot find class [com.sgss.nove.quartz.gallery.GalleryBulkJob]:

applicationcontext定义bean如下:

<bean id="galleryBulkTrigger" class="org.springframework.scheduling.quartz.CronTriggerBean">
<property name="jobDetail" ref="galleryBulkJob"/>
<property name="cronExpression" value="#{noveExternalProperties['cronExpression.galleryBulk']}"/>
</bean>

<bean id="galleryBulkJob" class="org.springframework.scheduling.quartz.JobDetailBean">
<property name="jobClass" value="com.sgss.nove.quartz.gallery.GalleryBulkJob"/>
<property name="jobDataAsMap">
<map>
<entry key="galleryBulkTask" value-ref="galleryBulkTask"/>
</map>
</property>
</bean>

和类(class)GalleryBulkJob如下:

import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.scheduling.quartz.QuartzJobBean;

public class GalleryBulkJob extends QuartzJobBean {

private GalleryBulkTask galleryBulkTask;

public void setGalleryBulkTask(GalleryBulkTask galleryBulkTask) {
this.galleryBulkTask = galleryBulkTask;
}

@Override
protected void executeInternal(JobExecutionContext jobExecutionContext) throws JobExecutionException {
galleryBulkTask.executeTask();
}
}

只要我知道它应该有效,唯一的疑问就是这一行:<property name="jobClass" value="com.sgss.nove.quartz.gallery.GalleryBulkJob"/>其中值被视为字符串,但需要一个类。

如何解决这个问题?

提前致谢。

最佳答案

可以将字符串传递给 Spring 上下文中的类参数。
看一下错误消息:找不到类[com.sgss.nove.quartz.gallery.GalleryBulkJob]。
由于某种原因,该类似乎不存在于类路径中。

关于java - 嵌套异常是 org.springframework.beans.TypeMismatchException :,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42925190/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com