Spring "SchedulerFactoryBean" 覆盖 "jobstore" 属性值
Spring "SchedulerFactoryBean" overrides the "jobstore" properties value
如果您正在使用 Spring 的 SchedulerFactoryBean,它会覆盖属性文件中的配置值。
因此,如果您尝试使用 JobStoreTx,它总是被来自 spring
的 LocalDataSourceJobStore 覆盖
下面的代码片段显示了 SchedulerFactoryBean 的部分。我已经通过使用定制器克服了它。
if (this.dataSource != null) {
mergedProps.setProperty(StdSchedulerFactory.PROP_JOB_STORE_CLASS, LocalDataSourceJobStore.class.getName());
}
使用 @QuartzDataSource
应该可以解决评论中提到的 @nonzaprej 的问题
这也是我如何使用定制器覆盖该值的方法
@Component
public class SchedulerFactoryCustomizer implements SchedulerFactoryBeanCustomizer {
使用自定义方法
@Override
public void customize(SchedulerFactoryBean schedulerFactoryBean) {
schedulerFactoryBean.setDataSource(dataSource);
}
如果您正在使用 Spring 的 SchedulerFactoryBean,它会覆盖属性文件中的配置值。 因此,如果您尝试使用 JobStoreTx,它总是被来自 spring
的 LocalDataSourceJobStore 覆盖下面的代码片段显示了 SchedulerFactoryBean 的部分。我已经通过使用定制器克服了它。
if (this.dataSource != null) {
mergedProps.setProperty(StdSchedulerFactory.PROP_JOB_STORE_CLASS, LocalDataSourceJobStore.class.getName());
}
使用 @QuartzDataSource
应该可以解决评论中提到的 @nonzaprej 的问题
这也是我如何使用定制器覆盖该值的方法
@Component
public class SchedulerFactoryCustomizer implements SchedulerFactoryBeanCustomizer {
使用自定义方法
@Override
public void customize(SchedulerFactoryBean schedulerFactoryBean) {
schedulerFactoryBean.setDataSource(dataSource);
}