Spring中applicationContext.xml的配置
<bean id="testJob" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
<property name="targetObject" ref="logService"/>
<property name="targetMethod" value="work"/>
</bean>
<bean id="testTrigger" class="org.springframework.scheduling.quartz.CronTriggerFactoryBean">
<property name="name" value="default"/>
<property name="group" value="default"/>
<property name="jobDetail" ref="testJob"/>
<property name="cronExpression" value="0/10 * * * * ?" />
</bean>
<bean id="testTrigger" class="org.springframework.scheduling.quartz.SimpleTriggerFactoryBean">
<property name="jobDetail" ref="testJob" />
<property name="startDelay" value="10000" />
<property name="repeatInterval" value="10000" />
</bean>
<bean id="scheduler" lazy-init="true" autowire="no" class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
<property name="triggers">
<list>
<ref bean="testTrigger"/>
</list>
</property>
</bean>
任务执行类
![这里写图片描述](https://img-blog.csdn.net/20170927151412167?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvZmVuZ3NoZW5nNTIxMA==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast)
执行效果
![这里写图片描述](https://img-blog.csdn.net/20170927151513011?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvZmVuZ3NoZW5nNTIxMA==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast)
关闭定时调度
Scheduler scheduler=(Scheduler) applicationContext.getBean("scheduler");
scheduler.shutdown();