环境:spring-context-support-4.0.5.RELEASE.jar(需要此包的\org\springframework\scheduling\quartz\)
<!-- 管理类 可以使用多个触发器 --> <!--lazy-init=‘false‘容器启动就会执行调度程序--> <bean id="taskManager" lazy-init="false" autowire="no" class="org.springframework.scheduling.quartz.SchedulerFactoryBean"> <property name="triggers"> <list> <ref bean="task_1" /> </list> </property> </bean> <!-- 定义触发器 --> <bean id="task_1" class="org.springframework.scheduling.quartz.CronTriggerBean"> <property name="jobDetail"> <ref bean="workDetail" /> </property> <!-- cron表达式 --> <property name="cronExpression"> <!-- 隔 1分钟执行一次--> <value>0 */1 * * * ?</value> </property> </bean> <!-- 实现 --> <bean id="workDetail" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean"> <!-- 引用实现的类 --> <property name="targetObject"> <ref bean="cancelTask" /> </property> <!-- 需要执行的方法 --> <property name="targetMethod"> <value>run</value> </property> </bean> <!-- 实现的类 --> <bean id="cancelTask" class="包.类"></bean>
Cron Expressions:
http://www.cnblogs.com/sunjie9606/archive/2012/03/15/2397626.html
时间: 2024-10-11 22:59:33