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. java.lang.IllegalArgumentException: Attribute 'items' is required and must be a Collection, an Array or a Map

    很有可能是涉及items的时候写成了item导致此错

  2. yii2 数据提供者 dataProvider

    数据提供者 dataProvider $dataProvider = new ActiveDataProvider([ 'query' => $query, // 如何来取得数据 'pagina ...

  3. pointer-net

    Pointer network 主要用在解决组合优化类问题(TSP, Convex Hull等等),实际上是Sequence to Sequence learning中encoder RNN和deco ...

  4. Vue(二十一)使用express模拟接口数据

    1.下载express ... 2.使用vue-cli下载好项目文件 ... 3.找到文件 build - webpack.dev.conf.js 'use strict' const utils = ...

  5. jQuery 学习(2)——jQuery选择器

    1.jQuery为元素添加CSS样式如下: <div id="tt1">单个样式:css()内"属性名称","value"< ...

  6. Redis的快照持久化-RDB与AOF

    Redis持久化功能 Redis为了内部数据的安全考虑,会把本身的数据以文件形式保存到硬盘中一份,在服务器重启之后会自动把硬盘的数据恢复到内存(redis)的里边. 数据保存到硬盘的过程就称为“持久化 ...

  7. 国内阿里maven仓库镜像maven配置文件maven仓库速度快

    国内连接maven官方的仓库更新依赖库,网速一般很慢,收集一些国内快速的maven仓库镜像以备用. 最新更新:2016年11月11日 18:05:40 阿里云提供Maven私服,我把配置文件贴一下,自 ...

  8. ionic1页面切换动画卡顿优化

    https://github.com/shprink/ionic-native-transitions https://www.npmjs.com/package/ionic-native-trans ...

  9. 为RecyclerView打造通用Adapter

    ##RecycleView简单介绍 RecyclerView控件和ListView的原理有非常多相似的地方,都是维护少量的View来进行显示大量的数据.只是RecyclerView控件比ListVie ...

  10. Clion使用MinGW编译好的boost库

    MinGW编译Boost库可以参考我之前写的编译Boost的文章. 以下是cmake链接boost静态库的配置: cmake_minimum_required(VERSION 3.8) project ...