我正在尝试在我的 Spring Boot 应用程序中实现一个 Quartz 调度程序;但是,我在启动后继续收到以下错误:
Caused by: java.sql.SQLSyntaxErrorException: ORA-00904: "SCHED_NAME": invalid identifier.
在错误之前的启动日志中,我看到:
liquibase : Successfully acquired change log lock
liquibase : Reading from PARTSVOICE_APP.DATABASECHANGELOG
liquibase : Successfully released change log lock
o.q.i.StdSchedulerFactory : Using default implementation for ThreadExecutor
o.q.c.SchedulerSignalerImpl : Initialized Scheduler Signaller of type: class org.quartz.core.SchedulerSignalerImpl
o.q.c.QuartzScheduler : Quartz Scheduler v.2.2.3 created.
o.s.s.q.LocalDataSourceJobStore : Using db table-based data access locking (synchronization).
o.s.s.q.LocalDataSourceJobStore : JobStoreCMT initialized.
o.q.c.QuartzScheduler : Scheduler meta-data: Quartz Scheduler (v2.2.3) 'scheduler' with instanceId 'NON_CLUSTERED'
Scheduler class: 'org.quartz.core.QuartzScheduler' - running locally.
NOT STARTED.
Currently in standby mode.
Number of jobs executed: 0
Using thread pool 'org.quartz.simpl.SimpleThreadPool' - with 25 threads.
Using job-store 'org.springframework.scheduling.quartz.LocalDataSourceJobStore' - which supports persistence. and is not clustered.
此消息令人担忧,因为在我的 application.yml 中,我的设置如下:
org:
quartz:
scheduler:
instanceName: cdp-scheduler
instanceId: AUTO
threadPool:
threadCount: 25
class: org.quartz.simpl.SimpleThreadPool
jobStore:
class: org.quartz.impl.jdbcjobstore.JobStoreTX
tablePrefix: c_
我阅读了这些属性并将它们放在此处的 SchedulerFactoryBean 中:
@Bean
public SchedulerFactoryBean scheduler(DataSource ds, SpringLiquibase dependent) throws SchedulerException, ConnectionException {
SchedulerFactoryBean factory = new SchedulerFactoryBean();
Properties quartzProps = new Properties();
quartzProps.setProperty("org.quartz.scheduler.instanceId", quartzConfig.getInstanceId());
quartzProps.setProperty("org.quartz.scheduler.instanceName", quartzConfig.getInstanceName());
quartzProps.setProperty("org.quartz.threadPool.threadCount", quartzConfig.getThreadCount());
quartzProps.setProperty("org.quartz.jobStore.class", quartzConfig.getJobStoreClass());
quartzProps.setProperty("org.quartz.jobStore.driverDelegateClass", "org.quartz.impl.jdbcjobstore.oracle.OracleDelegate");
quartzProps.setProperty("org.quartz.threadPool.class", quartzConfig.getThreadPoolClass());
factory.setOverwriteExistingJobs(true);
factory.setAutoStartup(false);
factory.setDataSource(ds);
factory.setQuartzProperties(quartzProps);
factory.setExposeSchedulerInRepository(true);
factory.setAutoStartup(true);
AutowiringSpringBeanJobFactory jobFactory = new AutowiringSpringBeanJobFactory();
jobFactory.setApplicationContext(applicationContext);
factory.setJobFactory(jobFactory);
return factory;
}
我正在尝试使用 org.quartz.impl.jdbcjobstore.JobStoreTX 类,以便我可以将 Quartz 信息存储在我们的数据库中。但是,我相信从上面的日志消息中可以看到,这已被覆盖。快速的 Google 搜索告诉我,如果您提供数据源,那么 JobStoreCMT 类会自动实现,但这对我来说没有意义。
我还使用 Liquibase 执行一个创建 quartz 表的 SQL 脚本,它执行得很好,它删除并创建了我需要的表。我也试过使用 Flybase 但我得到了同样的错误,所以它肯定与我的 quartz 设置有关。
有没有人有过类似的经历?有什么建议么?如果您认为我应该提供更多信息,请告诉我。谢谢。
最佳答案
对于该错误,我可以推断表未正确创建(根本没有创建或使用了错误的脚本)。对于 Quartz
,您需要使用适合您的数据库类型的 db 脚本创建表,您可以在 quartz download 中找到它。 .
这是一个类似的案例:https://groups.google.com/forum/#!topic/axonframework/IlWZ0UHK2hk
如果您认为脚本没问题,请尝试直接在您的数据库中创建表。
如果它仍然不起作用,您可以转到下一步并检查配置。也许您使用的 tablePrefix
没有得到很好的解释。尝试使用默认的 QRTZ_
。
这是一个使用较低版本的 Quartz
的设置示例。
http://www.opencodez.com/java/quartz-scheduler-with-spring-boot.htm
让我知道它是否有效!
关于java - Quartz 2.2.3 JobStore 属性被默认设置覆盖 - Spring Boot、Liquibase、Oracle,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48974695/