1、把quartz-*.jar 包放到lib目录下,他还需要 slf4j-api-*.jar 、 jta-*.jar
2、在web.xml文件中增加:
<!-- quartz begin -->
<context-param>
<param-name>config-file</param-name>
<param-value>/quartz.properties</param-value>
</context-param>
<context-param>
<param-name>shutdown-on-unload</param-name>
<param-value>true</param-value>
</context-param>
<listener>
<listener-class>
org.quartz.ee.servlet.QuartzInitializerListener
</listener-class>
</listener>
<!-- quartz end -->
3、在src目录下建立 quartz.properties
#============================================================================
# Configure Main Scheduler Properties
#============================================================================
org.quartz.scheduler.instanceName = DataSysScheduler
org.quartz.scheduler.instanceId = AUTO
#============================================================================
# Configure ThreadPool
#============================================================================
org.quartz.threadPool.class = org.quartz.simpl.SimpleThreadPool
org.quartz.threadPool.threadCount = 10
org.quartz.threadPool.threadPriority = 5
org.quartz.jobStore.misfireThreshold = 60000
org.quartz.jobStore.class =org.quartz.simpl.RAMJobStore
org.quartz.plugin.triggHistory.class = org.quartz.plugins.history.LoggingJobHistoryPlugin
org.quartz.plugin.jobInitializer.class = org.quartz.plugins.xml.XMLSchedulingDataProcessorPlugin
org.quartz.plugin.jobInitializer.fileNames = quartz_job.xml
org.quartz.plugin.jobInitializer.failOnFileNotFound = true
org.quartz.scheduler.skipUpdateCheck = true
4、在src目录下建立quartz_job.xml
<?xml version="1.0" encoding="UTF-8"?>
<job-scheduling-data xmlns="http://www.quartz-scheduler.org/xml/JobSchedulingData"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.quartz-scheduler.org/xml/JobSchedulingData http://www.quartz-scheduler.org/xml/job_scheduling_data_1_8.xsd"
version="1.8">
<pre-processing-commands>
<delete-jobs-in-group>*</delete-jobs-in-group> <!-- clear all jobs in scheduler -->
<delete-triggers-in-group>*</delete-triggers-in-group> <!-- clear all triggers in scheduler -->
</pre-processing-commands>
<processing-directives>
<!-- if there are any jobs/trigger in scheduler of same name (as in this file), overwrite them -->
<overwrite-existing-data>true</overwrite-existing-data>
<!-- if there are any jobs/trigger in scheduler of same name (as in this file), and over-write is false, ignore them rather then generating an error -->
<ignore-duplicates>false</ignore-duplicates>
</processing-directives>
<schedule>
<job>
<name>ParseDataJob</name>
<group>DataSys</group>
<description>数据解析job</description>
<job-class>esmart.datasys.quartzjob.ParseDataJob</job-class>
<volatility>false</volatility>
<durability>true</durability>
<recover>false</recover>
</job>
<trigger>
<cron>
<name>ParseDataTrigger</name>
<group>DataSys</group>
<job-name>ParseDataJob</job-name>
<job-group>DataSys</job-group>
<misfire-instruction>MISFIRE_INSTRUCTION_FIRE_ONCE_NOW</misfire-instruction>
<cron-expression>0/20 * * * * ?</cron-expression>
</cron>
</trigger>
</schedule>
</job-scheduling-data>
其中的 <job-class> 是自己定义的实现org.quartz.Job接口,有一个空的构造函数的类,