1.Xml配置 Spring-job.xml 并在 Spring-Application.xml中Import

<?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:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:task="http://www.springframework.org/schema/task"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-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.1.xsd"> <description>Spring Configuration</description>
<context:component-scan base-package="包的根目录例:com.xx.xx"/>
<!-- 配置任务线性池 -->
<task:executor id="executor" pool-size="10" />
<task:scheduler id="scheduler" pool-size="10"/>
<task:annotation-driven scheduler="scheduler" executor="executor" proxy-target-class="true"/>
<!-- 如果类文件中没有使用@Scheduled ,可以使用下面的配置 -->
<!--<task:scheduled-tasks scheduler="scheduler">
<task:scheduled ref="TestJob" method="test" cron="0/1 * * * * ?"/>
</task:scheduled-tasks>-->
</beans>

2.类文件TASK.java

import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component; @Component("TestJob")
public class ATask{
@Scheduled(cron = "0 9 16 * * ?")//每隔5秒隔行一次
public void test(){
System.out.println("job1 开始执行。。。。");
}
}

然后就可以了;

原文地址:https://blog.csdn.net/zhulin2012/article/details/51916612

SpringMvc自动任务调度之task实现项目源码,@Scheduled的更多相关文章

  1. java crm 进销存 springmvc SSM 项目 源码 系统

    系统介绍: 1.系统采用主流的 SSM 框架 jsp JSTL bootstrap html5 (PC浏览器使用) 2.springmvc +spring4.3.7+ mybaits3.3  SSM ...

  2. java 进销存管理 商户管理 库存管理 springmvc SSM 项目源码

    统介绍: 1.系统采用主流的 SSM 框架 jsp JSTL bootstrap html5 (PC浏览器使用) 2.springmvc +spring4.3.7+ mybaits3.3  SSM 普 ...

  3. java crm 系统 进销存 springmvc SSM项目项目源码

    统介绍: 1.系统采用主流的 SSM 框架 jsp JSTL bootstrap html5 (PC浏览器使用) 2.springmvc +spring4.3.7+ mybaits3.3  SSM 普 ...

  4. SpringMVC关于json、xml自动转换的原理研究[附带源码分析 --转

    SpringMVC关于json.xml自动转换的原理研究[附带源码分析] 原文地址:http://www.cnblogs.com/fangjian0423/p/springMVC-xml-json-c ...

  5. 反射实体自动生成EasyUi DataGrid模板 第二版--附项目源码

    之前写过一篇文章,地址 http://www.cnblogs.com/Bond/p/3469798.html   大概说了下怎么通过反射来自动生成对应EasyUi datagrid的模板,然后贴了很多 ...

  6. SpringMVC+Maven开发项目源码详细介绍

    代码地址如下:http://www.demodashi.com/demo/11638.html Spring MVC概述 Spring MVC框架是一个开源的Java平台,为开发强大的基于Java的W ...

  7. Java SSM 客户管理 商户 管理系统 库存管理 销售报表 项目源码

    系统介绍: 1.系统采用主流的 SSM 框架 jsp JSTL bootstrap html5 (PC浏览器使用) 2.springmvc +spring4.3.7+ mybaits3.3  SSM ...

  8. Java 商户管理系统 客户管理 库存管理 销售报表 SSM项目源码

    系统介绍: 1.系统采用主流的 SSM 框架 jsp JSTL bootstrap html5 (PC浏览器使用) 2.springmvc +spring4.3.7+ mybaits3.3  SSM ...

  9. Java SSM 商户管理系统 客户管理 库存管理 销售报表 项目源码

    需求分析: 有个厂家,下面有很多代理商(商户或门头等),之前商户进货.库存.销售.客户资料等记录在excel表格中 或者无记录,管理比较混乱,盈利情况不明.不能有效了解店铺经营情况和客户跟踪记录 厂家 ...

随机推荐

  1. Django复习1

    django常用命令:http://www.cnblogs.com/ldq1996/p/7731930.html Django查询SQL语句: http://www.cnblogs.com/ldq19 ...

  2. 考前停课集训 Day1 废

    [友情链接] Day1 今天模拟赛倒数…… 感觉自己菜到爆炸…… 被一个以前初一的倒数爆踩…… 感觉自己白学了. 满分400,自己只有100.真的是倒数第一…… 做了一个T2,其他暴力分全部没有拿到… ...

  3. Android RxJava

    GitHut 地址: https://github.com/ReactiveX/RxAndroid build.gradle: compile 'io.reactivex:rxandroid:1.2. ...

  4. hdu 6034 B - Balala Power! 贪心

    B - Balala Power! 题目链接 http://acm.hdu.edu.cn/showproblem.php?pid=6034 题面描述 Talented Mr.Tang has n st ...

  5. 防止APACHE解析漏洞

    一.PHP端,规范代码,加强尾缀验证 二.Apache端,在httpd.conf中加上如下代码: <Files~"\.(p|P)(h|H)(p|P)."> Deny f ...

  6. cookie 跨域解决方法

    1.Nginx 正向和反向代理的区别 正向代理和反向代理的区别:正向代理隐藏真实客户端,反向代理隐藏真实服务端,图示: 2.cookie跨域问题 因为cookie存在跨域问题,其中一个解决方法是,设置 ...

  7. WebApp开发技术搭配

    一:Ionic + angular + cordova + zipalign UI框架:lonic+angular 开发与编译打包框架:Cordova 优化工具:zipalign 二:MUI+HBui ...

  8. C#缓存absoluteExpiration、slidingExpiration两个参数的疑惑

    看了很多资料终于搞明白cache中absoluteExpiration,slidingExpiration这两个参数的含义. absoluteExpiration:用于设置绝对过期时间,它表示只要时间 ...

  9. 使用h5py操作hdf5文件

    HDF(Hierarchical Data Format)指一种为存储和处理大容量科学数据设计的文件格式及相应库文件.HDF 最早由美国国家超级计算应用中心 NCSA 开发,目前在非盈利组织 HDF ...

  10. Spark 公共篇-InterfaceStability

    本章内容: 1.源码 InterfaceStability 类包含三个注解,用于说明被他们注解的类型的稳定性. /** * Annotation to inform users of how much ...