spring定时器
Posted miu丶苏
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了spring定时器相关的知识,希望对你有一定的参考价值。
applicationContext-timer.xml
<?xml version="1.0" encoding="GBK"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:osgi="http://www.springframework.org/schema/osgi"
xmlns:esb="http://mule.mulesource.org/schema/esb"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/osgi http://www.springframework.org/schema/osgi/spring-osgi.xsd
http://mule.mulesource.org/schema/esb http://mule.mulesource.org/schema/esb.xsd">
<bean id="waybillTimerTask" class="com.golden.ex.ts.timer.WaybillTimerTask" />
<bean id="scheduleWaybillTimerTask" class="org.springframework.scheduling.timer.ScheduledTimerTask">
<property name="delay" value="60000" />
<property name="period" value="60000"/>
<property name="timerTask" ref="waybillTimerTask" />
</bean>
<bean id="timerFactory" class="org.springframework.scheduling.timer.TimerFactoryBean">
<property name="scheduledTimerTasks">
<list>
<ref bean="scheduleWaybillTimerTask"/>
<ref bean="scheduleWaybillViewTimerTask" />
</list>
</property>
</bean>
WaybillTimerTask .java
@Override
public void run() {
try {
// 接单处理定时器
confirm();//方法名
} catch (Exception e) {
logger.error("接单处理定时器异常:" + e.getMessage());
}
try {
// 预约运单处理定时器
appoint();//方法名
} catch (Exception e) {
logger.error("预约运单处理定时器异常:" + e.getMessage());
}
}
以上是关于spring定时器的主要内容,如果未能解决你的问题,请参考以下文章