spring task

xiaoxiao2021-02-28  59

必须注意的是taskMgr必须是spring可管理的类。 task:scheduler 为线程池配置 task:scheduled-tasks 为具体定时任务配置

<?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.3.xsd http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-4.3.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.3.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.3.xsd http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-4.3.xsd"> <context:component-scan base-package="扫描目录" /> <task:annotation-driven /> <task:scheduler id="taskDemo" pool-size="8" /> <task:scheduled-tasks scheduler="taskDemo"> <task:scheduled ref="taskMgr" method="doSchedPerHour" cron="0 0 */1 * * ?" /> </task:scheduled-tasks> </beans>
转载请注明原文地址: https://www.6miu.com/read-50581.html

最新回复(0)