Quartz-Job支持声明式的编程,这样我们在项目部署后需要对某个任务进行更改或者新增job任务时,不用再重新编译代码发布,而只需更改quartz-job对应的XML配置文件类似于spring的bean文件
I.SimpleTrigger
- <?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_2_0.xsd"
- version="2.0">
- <schedule>
- <!-- job1 -->
- <job>
- <name>MyJob1</name>
- <group>group1</group>
- <description>
- 通过配置文件来执行job任务
- </description>
- <job-class>
- com.swh.jobweb.process.MyJob6
- </job-class>
- <durability>false</durability>
- <recover>false</recover>
- <!--
- <job-data-map allows-transient-data="true">
- <entry>
- <key>JOB_DATA_MAP_KEY</key>
- <value>key</value>
- </entry>
- </job-data-map>
- -->
- </job>
- <trigger>
- <simple>
- <name>trigger1</name>
- <group>group1</group>
- <job-name>MyJob1</job-name>
- <job-group>group1</job-group>
- <start-time>2015-10-17T00:17:00</start-time>
- <!-- repeat indefinitely every 10 seconds -->
- <repeat-count>-1</repeat-count>
- <repeat-interval>10000</repeat-interval>
- </simple>
- </trigger>
- <!-- job2 -->
- <job>
- <name>MyJob2</name>
- <group>group1</group>
- <description>
- 通过配置文件来执行job任务
- </description>
- <job-class>
- com.swh.jobweb.process.MyJob6
- </job-class>
- <durability>false</durability>
- <recover>false</recover>
- <!--
- <job-data-map allows-transient-data="true">
- <entry>
- <key>JOB_DATA_MAP_KEY</key>
- <value>key</value>
- </entry>
- </job-data-map>
- -->
- </job>
- <trigger>
- <simple>
- <name>trigger2</name>
- <group>group1</group>
- <job-name>MyJob2</job-name>
- <job-group>group1</job-group>
- <start-time>2015-10-17T00:17:20</start-time>
- <!-- repeat indefinitely every 10 seconds -->
- <repeat-count>-1</repeat-count>
- <repeat-interval>10000</repeat-interval>
- </simple>
- </trigger>
- </schedule>
- </job-scheduling-data>