gpt4 book ai didi

java - 如何为 org.quartz.JobDetail 创建自定义编辑器?

转载 作者:行者123 更新时间:2023-12-01 15:15:24 25 4
gpt4 key购买 nike

我正在尝试使用 Spring 设置 CronTriggerFactoryBean,它有一个名为 JobDetail 的属性,我正在尝试初始化该属性。

  <bean id="cronTrigger" class="org.springframework.scheduling.quartz.CronTriggerFactoryBean">
<property name="name" value="NTrigger"></property>
<property name="group" value="Group Trigger"></property>
<property name="jobDetail" value="Group Trigger"></property>
<property name="cronExpression" value="${quartz.slaPollerCronExpression.timeInterval}"></property>
</bean>

但是我收到一个错误:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name
'cronTriggerForSLAPoller' defined in ServletContext resource [/WEB-INF/config/quartz
-config.xml]: Initialization of bean failed; nested exception is
org.springframework.beans.ConversionNotSupportedException: Failed to convert property value
of type 'java.lang.String' to required type 'org.quartz.JobDetail' for property
'jobDetail'; nested exception is java.lang.IllegalStateException:
Cannot convert value of type [java.lang.String] to required type [org.quartz.JobDetail
for property 'jobDetail': no matching editors or conversion strategy found.

我认为它采用String作为默认类型。

我查看了[propertyeditors][1]。我想我需要使用ClassEditor。我的想法正确吗?

如何消除此错误?我如何为此创建自定义编辑器?

最佳答案

看来您需要传递引用而不是字符串:

Failed to convert property value of type 'java.lang.String' to required type 'org.quartz.JobDetail' for property 'jobDetail'

CronTriggerFactoryBean

/**
* Set the JobDetail that this trigger should be associated with.
*/
public void setJobDetail(JobDetail jobDetail) {
this.jobDetail = jobDetail;
}

参见 Chapter 23. Scheduling and Thread Pooling

<bean id="exampleJob" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
<property name="targetObject" ref="exampleBusinessObject" />
<property name="targetMethod" value="doIt" />
<property name="concurrent" value="false" />
</bean>


<bean id="cronTrigger" class="org.springframework.scheduling.quartz.CronTriggerBean">
<property name="jobDetail" ref="exampleJob" />
<!-- Runs every morning at 6 AM -->
<property name="cronExpression" value="0 0 6 * * ?" />
</bean>

关于java - 如何为 org.quartz.JobDetail 创建自定义编辑器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11670358/

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