gpt4 book ai didi

java - 使用 Spring 框架的 Quartz JobStore

转载 作者:IT老高 更新时间:2023-10-28 13:57:09 25 4
gpt4 key购买 nike

我正在使用 Spring Framework 在 Oracle DB 上实现 Quartz Job Store。我的 ApplicationContext.xml 在下面

<bean id="driverJob" class="org.springframework.scheduling.quartz.JobDetailBean">
<property name="jobClass" value="BatchFileCollector" />
</bean>

<bean id="ranchTrigger" class="org.springframework.scheduling.quartz.SimpleTriggerBean">
<property name="jobDetail" ref="driverJob" />
<property name="startDelay" value="2000" />
<property name="repeatInterval" value="10000" />
</bean>

<bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
<property name="triggers">
<list>
<ref bean="ranchTrigger" />
</list>
</property>
<property name="dataSource">
<ref bean="dataSource.TEXAN"/>
</property>
<property name="applicationContextSchedulerContextKey">
<value>applicationContext</value>
</property>
<property name="autoStartup">
<value>true</value>
</property>
<property name="configLocation" value="classpath:quartz.properties"/>
</bean>

此配置给我以下错误。

Caused by: org.quartz.JobPersistenceException: 

Couldn't store trigger: The job (DEFAULT.driverJob) referenced by the trigger does not exist.

[See nested exception: org.quartz.JobPersistenceException: The job (DEFAULT.driverJob) referenced by the trigger does not exist.]

我正在使用 Spring Framework 2.5.6。我必须升级我的 Quartz 版本吗?我找不到问题。

感谢您的帮助。

最佳答案

您的 SchedulerFactoryBean 也需要注册“driverJob”。除了您的触发器,添加一个 jobDetails 列表。

<bean id="job.statistics.DailyQPSValidationJobTrigger" class="org.quartz.CronTrigger">
<property name="name" value="DailyQPSValidationTrigger" />
<property name="jobName" value="DailyQPSValidation" />
<property name="jobGroup" value="Statistics" />
<property name="volatility" value="false" />
<!-- Each day, 4 o'clock AM -->
<property name="cronExpression" value="0 0 4 * * ?" />
</bean>

<!-- Scheduler -->

<bean id="job.SchedulerProperties" class="somecompany.someproduct.util.spring.PropertiesFactoryBean"
scope="singleton">
<property name="source">
<props>
<prop key="org.quartz.scheduler.instanceId">AUTO</prop>
<prop key="org.quartz.scheduler.instanceName">JobCluster</prop>
<prop key="org.quartz.jobStore.class">org.quartz.impl.jdbcjobstore.JobStoreTX</prop>
<prop key="org.quartz.jobStore.driverDelegateClass">org.quartz.impl.jdbcjobstore.StdJDBCDelegate</prop>
<prop key="org.quartz.jobStore.isClustered">true</prop>
<prop key="org.quartz.jobStore.useProperties">false</prop>
</props>
</property>
</bean>

<bean id="job.Scheduler" class="org.springframework.scheduling.quartz.SchedulerFactoryBean" scope="singleton"
lazy-init="false">
<property name="startupDelay" value="30" />
<property name="waitForJobsToCompleteOnShutdown" value="true" />
<property name="dataSource" ref="jdbc.DataSource" />
<property name="quartzProperties" ref="job.SchedulerProperties" />
<property name="jobDetails">
<list>
<ref bean="job.statistics.DailyQPSValidationJobDetail" />
</list>
</property>
<property name="triggers">
<list>
<ref bean="job.statistics.DailyQPSValidationJobTrigger" />
</list>
</property>
<property name="schedulerListeners">
<list>
<bean class="somecompany.someproduct.job.SchedulerErrorListener">
<property name="monitoringService" ref="monitoring.MonitoringService" />
</bean>
</list>
</property>
<property name="globalJobListeners">
<list>
<bean class="somecompany.someproduct.job.JobErrorListener">
<property name="name" value="JobErrorListener" />
<property name="monitoringService" ref="monitoring.MonitoringService" />
</bean>
</list>
</property>
</bean>

关于java - 使用 Spring 框架的 Quartz JobStore,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1187882/

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