欢迎使用CSDN-markdown编辑器

来源:互联网 发布:苹果anywhere软件 编辑:程序博客网 时间:2024/06/12 23:59

spring.xml 配置

<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">      <!-- 自动扫描该包,使SpringMVC认为包下用了@controller注解的类是控制器 -->    <context:component-scan base-package="com.example.scheduler" />    <task:executor id="executor" pool-size="5" />    <task:scheduler id="scheduler" pool-size="10" />    <task:annotation-driven executor="executor" scheduler="scheduler" /></beans>

java中 注解

@Component(“erpOrderSyn”)
@EnableScheduling()

@Scheduled(cron = “0 0 8,12,17,0 * * ? “)

参考

1.Spring Task定时任务的配置和使用
2.Spring4最简单的方式创建定时任务

原创粉丝点击