我创建了文件quartz.properties
并将其放在classpath中。属性是
org.quartz.threadPool.class = org.quartz.simpl.SimpleThreadPool
org.quartz.threadPool.threadCount = 1
但是当我启动应用程序时,我收到了这条消息
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 10 threads.
Using job-store 'org.quartz.simpl.RAMJobStore' - which does not support persistence. and is not clustered.
是加载属性还是不加载?无论如何我只为调度程序运行一个线程...
当我使用spring
时,我确实喜欢这个。我在我的常见properties
文件中创建了一个属性
quartz.threadPool.threadCount=1
然后在我的xml中设置quartzProperties
的字段ScheduleFactoryBean
<property name="quartzProperties">
<util:properties>
<prop key="org.quartz.threadPool.threadCount">
${quartz.threadPool.threadCount}
</prop>
</util:properties>
</property>
@NikNik
org.quartz.threadPool.threadCount
数据类型必须是String所以它应该是
p.put(“org.quartz.threadPool.threadCount”,“2”);
...
StdSchedulerFactory factory = new StdSchedulerFactory(p);
它可能没有加载您的属性文件。但是,要避免使用属性,可以使用java配置来配置调度程序:
Properties p = new Properties();
p.put("org.quartz.scheduler.instanceName", "Scheduler_test");
p.put("org.quartz.threadPool.threadCount", 2);
...
StdSchedulerFactory factory = new StdSchedulerFactory(p);
如果您使用带注释的弹簧配置:
@Bean
public SchedulerFactoryBean schedulerFactoryBean() {
SchedulerFactoryBean scheduler = new SchedulerFactoryBean();
Properties quartzProperties = new Properties();
quartzProperties.put("org.quartz.threadPool.threadCount", "1");
scheduler.setQuartzProperties(quartzProperties);
...
return scheduler;
}