<!---加入:xmlns:task="http://www.springframework.org/schema/task"-->
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:task="http://www.springframework.org/schema/task"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.2.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.2.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.2.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd
http://www.springframework.org/schema/task
http://www.springframework.org/schema/task/spring-task-3.2.xsd">
<task:annotation-driven /> <!-- 定时器开关-->
<bean id="myTaskXml" class="com.chaohaoyun.common.SpringTask"></bean>
<!-- 自动扫描的包名 -->
<context:component-scan base-package="com.chaohaoyun.common" />
</beans>
package com.chaohaoyun.common;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import com.chaohaoyun.patientreservation.bean.Patientreservation;
import com.chaohaoyun.patientreservation.service.PatientreservationService;
@Component
public class SpringTask {
@Scheduled(cron="0 0/30 8-18 * * ? ") //朝九晚五每半小时执行一次
public void show() throws ParseException {
执行任务
}
}