日期:2014-05-17  浏览次数:20683 次

Quartz定时机制设置每天凌晨2点却执行好几遍?
Java code

<?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="statisticsService"
        class="Stat.service.impl.StatisticsServiceImpl">
    </bean>

    <bean id="statisticsServiceDetail"
        class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
        <property name="targetObject">
            <ref bean="statisticsService" />
        </property>
        <property name="targetMethod">
            <value>test</value>
        </property>
    </bean>


    <!-- 配置调度任务,复杂定制模式,月份中的日期和星期不能同时设置   -->
    <bean id="cronReportTrigger"
        class="org.springframework.scheduling.quartz.CronTriggerBean">
        <property name="jobDetail">
            <ref bean="statisticsServiceDetail" />
        </property>
        <property name="cronExpression">
            <value>0 0 2 ? * *</value>
        </property>
    </bean>

    <!-- 启动调度 -->
    <bean id="start"
        class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
        <property name="triggers">
            <list>
                <ref bean="cronReportTrigger" />
            </list>
        </property>
    </bean>
</beans>



------解决方案--------------------
0 0 2 × × ×
------解决方案--------------------
0 0 2 * * ?
------解决方案--------------------
时间的设置是没有问题的。。是容器的问题,具体我也忘了。。以前遇到过
 你百度输入“cronExpression” 有相关的文章。
------解决方案--------------------
0 0 2 * * ?

http://www.blogjava.net/xmatthew/archive/2009/02/15/253864.html