首页 > 代码库 > 定时任务
定时任务
Naims_task.xml
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" xmlns:task="http://www.springframework.org/schema/task" xmlns:context="http://www.springframework.org/schema/context" xmlns:aop="http://www.springframework.org/schema/aop" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.0.xsd http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-4.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.0.xsd http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-4.0.xsd"> <task:annotation-driven /> <!-- 定时器开关--> <bean id="myTask" class="com.wisoft.jazwfw.convenienceServices.controller.ConvenienceServicesController"></bean> <task:scheduled-tasks> <!-- 这里表示的是每天23点59分执行一次 --> <task:scheduled ref="myTask" method="getPubService" cron="0 59 23 * * ?" /> <!-- 这里表示的是每隔十秒执行一次 --> <!-- <task:scheduled ref="myTask" method="print" cron="*/10 * * * * ?"/> --> </task:scheduled-tasks> <!-- 自动扫描的包名 --> <context:component-scan base-package="com.wisoft.jazwfw.convenienceServices.controller" /> </beans>
然后在Naims_main.xml引入
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd"> <beans> <import resource="spring/Naims_ws.xml" /> <import resource="spring/Naims_bo.xml" /> <import resource="spring/Naims_dao.xml"/> <import resource="spring/Naims_params.xml"/> <import resource="spring/Naims_task.xml"/> </beans>
定时任务
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。