我试图解决避免长时间加载默认quartz.properties文件的问题。希望有人可以在这里伸出援手。非常感谢!
基本上,我已经阅读了很多关于这个问题的帖子,而他们的解决方案并没有解决我的问题。我已将quartz.properties 文件放在WEB-INF/classes 下,以下是我在web.xml 中使用上下文侦听器的配置:
<context-param>
<param-name>quartz:config-file</param-name>
<param-value>quartz.properties</param-value>
</context-param>
<context-param>
<param-name>quartz:shutdown-on-unload</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<param-name>quartz:wait-on-shutdown</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<param-name>quartz:start-on-load</param-name>
<param-value>true</param-value>
</context-param>
<listener>
<listener-class>
org.quartz.ee.servlet.QuartzInitializerListener
</listener-class>
</listener>
结果仍然显示如下:
[INFO] 18 Feb 06:37:29.218 PM main [org.quartz.impl.StdSchedulerFactory]
Using default implementation for ThreadExecutor
[INFO] 18 Feb 06:37:29.265 PM main [org.quartz.core.SchedulerSignalerImpl]
Initialized Scheduler Signaller of type: class org.quartz.core.SchedulerSignalerImpl
[INFO] 18 Feb 06:37:29.265 PM main [org.quartz.core.QuartzScheduler]
Quartz Scheduler v.2.1.6 created.
[INFO] 18 Feb 06:37:29.265 PM main [org.quartz.simpl.RAMJobStore]
RAMJobStore initialized.
[INFO] 18 Feb 06:37:29.281 PM main [org.quartz.core.QuartzScheduler]
Scheduler meta-data: Quartz Scheduler (v2.1.6) 'MyQuartzTest' 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 12 threads.
Using job-store 'org.quartz.simpl.RAMJobStore' - which does not support persistence. and is not clustered.
[INFO] 18 Feb 06:37:29.281 PM main [org.quartz.impl.StdSchedulerFactory]
Quartz scheduler 'MyQuartzTest' initialized from default resource file in Quartz package: 'quartz.properties'
[INFO] 18 Feb 06:37:29.281 PM main [org.quartz.impl.StdSchedulerFactory]
Quartz scheduler version: 2.1.6
[INFO] 18 Feb 06:37:29.281 PM main [org.quartz.core.QuartzScheduler]
Scheduler MyQuartzTest_$_NON_CLUSTERED started.
[INFO] 18 Feb 06:37:29.312 PM MyQuartzTest_Worker-1 [org.quartz.examples.example1.HelloJob]
Hello World! - Mon Feb 18 18:37:29 GMT+08:00 2013
[INFO] 18 Feb 06:38:09.296 PM MyQuartzTest_Worker-2 [org.quartz.examples.example1.HelloJob]
Hello World! - Mon Feb 18 18:38:09 GMT+08:00 2013
[INFO] 18 Feb 06:38:29.296 PM main [org.quartz.core.QuartzScheduler]
Scheduler MyQuartzTest_$_NON_CLUSTERED shutting down.
[INFO] 18 Feb 06:38:29.296 PM main [org.quartz.core.QuartzScheduler]
Scheduler MyQuartzTest_$_NON_CLUSTERED paused.
[INFO] 18 Feb 06:38:29.296 PM main [org.quartz.core.QuartzScheduler]
Scheduler MyQuartzTest_$_NON_CLUSTERED shutdown complete.
我的另一个困惑是,如果它真的在加载默认的quartz.properties 文件,那么为什么线程池和调度程序名称是根据我自定义的quartz.properties 文件正确设置的?
另一方面,我也尝试根据 Quartz 的官方文档QuartzInitializerListner为 quartz.properties 文件设置不同的路径。例如:
<context-param>
<param-name>quartz:config-file</param-name>
<param-value>/MyProject/WEB-INF/my_quartz.properties</param-value>
</context-param>
结果显示更糟。这将是完全默认设置。因此,我现在很迷茫。请详细说明这种情况的根本原因。非常感谢!