Quartz的Spring配置
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
<!-- 要调用的工作类 -->
<bean id="job" class="com.mv.newspider.threesnews.NewsFrom3s">
</bean>
<!-- 定义调用对象和调用对象的方法 -->
<bean id="jobtask"
class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
<!-- 调用的类 -->
<property name="targetObject" ref="job" />
<!-- 调用类中的方法 -->
<property name="targetMethod" value="work" />
<!-- 并发处理 -->
<property name="concurrent" value="false" />
</bean>
<!-- 表达式触发器 -->
<bean id="doTime"
class="org.springframework.scheduling.quartz.CronTriggerFactoryBean">
<property name="jobDetail" ref="jobtask" />
<!-- cron表达式 -->
<property name="cronExpression" value="0 20 10 ? * MON" />
</bean>
<!-- 简单触发器:定义触发规则 -->
<bean id="synJob"
class="org.springframework.scheduling.quartz.SimpleTriggerFactoryBean">
<property name="jobDetail" ref="jobtask" />
<!-- 服务启动一分钟后执行 1*1000*60 -->
<property name="startDelay" value="1" />
<!-- 每隔6秒执行一次 6*1000 -->
<property name="repeatInterval" value="7200000" />
</bean>
<!-- 总管理类 如果将lazy-init='false'那么容器启动就会执行调度程序 -->
<bean id="startQuertz" lazy-init="false" autowire="no"
class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
<property name="triggers">
<list>
<ref bean="doTime" />
</list>
</property>
</bean>
</beans>