定时任务
Posted jassy
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了定时任务相关的知识,希望对你有一定的参考价值。
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>
以上是关于定时任务的主要内容,如果未能解决你的问题,请参考以下文章