我正在使用Quartz作为应用程序,并且没有quartz.properties文件它工作正常。 当我包含quartz.properties以使用JDBCJobStore时,会给出以下异常
Exception in thread "main" org.quartz.SchedulerConfigException: Unable to instantiate JobFactory class: org.quartz.impl.StdSchedulerFactory cannot be cast to org.quartz.spi.JobFactory [See nested exception: java.lang.ClassCastException: org.quartz.impl.StdSchedulerFactory cannot be cast to org.quartz.spi.JobFactory]
at org.quartz.impl.StdSchedulerFactory.instantiate(StdSchedulerFactory.java:785) at org.quartz.impl.StdSchedulerFactory.instantiate(StdSchedulerFactory.java:785)
at org.quartz.impl.StdSchedulerFactory.getScheduler(StdSchedulerFactory.java:1502)
计划班级
public class CronTriggerExample {
public static void main( String[] args ) throws Exception
{
JobKey jobKeyA = new JobKey("jobA", "group1");
JobDetail jobA = JobBuilder.newJob(JobB.class)
.withIdentity(jobKeyA).storeDurably(true).build();
Trigger trigger1 = TriggerBuilder
.newTrigger()
.withIdentity("dummyTriggerName1", "group1")
.withSchedule(
CronScheduleBuilder.cronSchedule("0/5 * * * * ?"))
.build();
SchedulerFactory schdFact = new StdSchedulerFactory();
Scheduler schd = schdFact.getScheduler();
schd.start();
schd.scheduleJob(jobA, trigger1);
}
}
quartz.properties
# Main Quartz configuration
org.quartz.scheduler.skipUpdateCheck = true
org.quartz.scheduler.instanceName = MyQuartzScheduler
org.quartz.scheduler.jobFactory.class = org.quartz.impl.StdSchedulerFactory
org.quartz.threadPool.class = org.quartz.simpl.SimpleThreadPool
org.quartz.threadPool.threadCount = 5
org.quartz.jobStore.tablePrefix = QRTZ_
org.quartz.jobStore.useProperties=false
org.quartz.jobStore.dataSource = myDS
org.quartz.dataSource.myDS.driver=com.mysql.jdbc.Driver
org.quartz.dataSource.myDS.URL=jdbc:mysql://localhost:3306/quartz
org.quartz.dataSource.myDS.user=root
org.quartz.dataSource.myDS.password=root
org.quartz.jobStore.class = org.quartz.impl.jdbcjobstore.JobStoreTX
org.quartz.jobStore.tablePrefix = QRTZ_
org.quartz.dataSource.quartzDataSource.maxConnections = 5
答案 0 :(得分:0)
我已将以下代码行添加到属性文件
org.quartz.jobStore.driverDelegateClass = org.quartz.impl.jdbcjobstore.MSSQLDelegate
并删除
org.quartz.jobStore.useProperties=false
现在工作正常。