1.java
<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd"> <beans> <bean name="job" class="com.siyuan.test.quartz.job.LogJob"></bean> <bean name="jobDetail" class="frameworkx.springframework.scheduling.quartz.BeanInvokingJobDetailFactoryBean"> <property name="targetBean" value="job" /> <property name="targetMethod" value="execute" /> <property name="group" value="scheduler" /> <!-- <property name="shouldRecover" value="true" /> --> </bean> <bean name="trigger" class="org.springframework.scheduling.quartz.CronTriggerBean"> <property name="jobDetail" ref="jobDetail" /> <property name="cronExpression" value="0/2 * * * * ?" /> <property name="name" value="trigger" /> <property name="group" value="scheduler" /> </bean> <bean name="scheduler" class="org.springframework.scheduling.quartz.SchedulerFactoryBean"> <property name="triggers"> <list> <ref bean="trigger" /> </list> </property> <property name="configLocation" value="classpath:quartz.properties"/> <!-- <property name="overwriteExistingJobs" value="true" /> --> </bean> </beans>
必須使用frameworkx.springframework.scheduling.quartz.BeanInvokingJobDetailFactoryBeanspring
或者frameworkx.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean,spa
直接使用org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean會報java.io.NotSerializableException異常,參考http://jira.springframework.org/browse/SPR-3797code
這裏也能夠本身寫一個類繼承QuartzJobBean來做爲咱們要執行的Jobxml
shouldRecover 當Quartz服務被停止後,再次啓動或集羣中其餘機器接手任務時會嘗試恢復執行以前未完成的全部任務繼承
overwriteExistingJobs 必須設置爲TRUE,不然配置文件中的更新沒法影響DB已存在的信息get
經過NAME和GROUP識別it
quartz.properties:io
#org.quartz.jobStore.isClustered = trueclass
#org.quartz.jobStore.clusterCheckinInterval = 20000