首页 > 代码库 > 关于Quartz定时器的配置

关于Quartz定时器的配置

<!-- scheduler 触发器启动配置-->

<bean id="scheduler" class="org.springframework.scheduling.quartz.SchedulerFactoryBean">

    <property name="triggers">

      <list>

        <ref local="saveCronTrigger" />

        <ref local="connectTrigger" />

        <ref local="resetControlUnitVillageTrigger" />

        <ref local="autoExamineConnMPSDetailTrigger"/>

        <ref local="connMpsResourceTrigger"/>

        <ref local="smsSendTrigger"/>

    </list>

    </property>

</bean>


<!--发送短信 定时器配置 -->

<bean id="smsSendQuartz" class="org.gagb.service.impl.manage.login.LoginServiceImpl">

    <property name="loginDao" ref="loginDao" />

</bean>


<!-- jobDetail -->

<bean id="smsSendJobDetail"     class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">

    <property name="targetObject">

        <ref bean="smsSendQuartz" />

    </property>

    <property name="targetMethod">

    <value>sendMessageReal</value><!--需要定时执行的方法-->

    </property>

</bean>


<!-- trigger -->

<bean id="smsSendTrigger" class="org.springframework.scheduling.quartz.CronTriggerBean">

<property name="jobDetail">

<ref bean="smsSendJobDetail" />

</property>

<property name="cronExpression">

<!-- 0 0 23 * * ?  每天晚上23点触发 -->

<!-- 0 0 */8 * * ? 每8个小时触发 -->

<!-- 0 0/5 * * * ? 每5分钟触发 -->

<value>*/3 * * * * ?</value>  <!-- 每3秒触发 -->

</property>

</bean>


技术分享

本文出自 “画江湖之不良人” 博客,转载请与作者联系!

关于Quartz定时器的配置