dellplay 发表于 2015-4-19 14:14:03

请问定时任务如何使用

我写了一个service,然后在spring-mvc-timetask.xml里添加进去。数据库里也仿照例子添加了记录。
但是部署到Tomcat报错。
spring-mvc-timetask代码如下:
<!-- 定时任务配置 scheduler 方式 注解 暂时不支持动态更新 -->
        <context:component-scan base-package="org.jeecgframework.core.timer" />
        <task:executor id="executor" pool-size="5" />
        <task:scheduler id="scheduler" pool-size="10" />
        <task:annotation-driven executor="executor"
                scheduler="scheduler" />
        <!-- 定时任务配置 quartz 可配置到管理界面 -->
        <bean id="taskDemoServiceTaskJob"
                class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
                <property name="targetObject" ref="taskDemoService" />
                <property name="targetMethod" value="work" />
                <property name="concurrent" value="true" />
        </bean>

        <bean id="taskDemoServiceTaskCronTrigger" class="org.jeecgframework.core.timer.DataBaseCronTriggerBean">
                <property name="jobDetail" ref="taskDemoServiceTaskJob" />
                <property name="cronExpression" value="0 0/1 * * * ?" />
        </bean>
<bean id="autoElecPrintServiceTaskJob"
                class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
                <property name="targetObject" ref="autoElecPrintService" />
                <property name="targetMethod" value="work" />
                <property name="concurrent" value="true" />
        </bean>

        <bean id="autoElecPrintServiceTaskCronTrigger" class="org.jeecgframework.core.timer.DataBaseCronTriggerBean">
                <property name="jobDetail" ref="autoElecPrintServiceTaskJob" />
                <property name="cronExpression" value="0 0 6 * * * " />
        </bean>
        <!-- 定时任务调度器 -->
        <bean id="schedulerFactory" lazy-init="false" autowire="no"
                class="org.jeecgframework.core.timer.DataBaseSchedulerFactoryBean">
                <property name="triggers">
                        <list>
                                <ref bean="taskDemoServiceTaskCronTrigger" />
                                <ref bean="autoElecPrintServiceTaskCronTrigger" />
                        </list>
                </property>
        </bean>

</beans>
页: [1]
查看完整版本: 请问定时任务如何使用