您的位置:首页 > 编程语言 > Java开发

定时器quartz结合spring使用(方法二MethodInvokingJobDetailFactoryBean)

2017-08-15 09:56 771 查看
xml配置

<bean name="scheduler" lazy-init="false" autowire="no" class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
<property name="triggers">
<list>
<ref bean="syncJobDock" />
</list>
</property>
</bean>
<bean id="syncJobDock" class="org.springframework.scheduling.quartz.CronTriggerBean">
<property name="jobDetail" ref="syncJobDetail"></property>
<property name="cronExpression">
<value>0 53 17 * * ?</value>
</property>
</bean>
<bean id="syncJobDetail" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
<property name="targetObject">
<ref bean="onkey" />
</property>
<property name="targetMethod">
<value>executeInternal</value>
</property>
</bean>
<bean id ="onkey" class="com.xxx"></bean>
定时器任务类
public class XXX{
private static final Logger LOG = Logger.getLogger(XXX.class);

/**
* 要调度的具体任务
*/
protected void executeInternal(){
LOG.info("定时任务执行开始…");

LOG.info("定时任务执行结束…");
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐