1、创建定时任务
package com.*.task;
import java.util.Date;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import com.*.core.util.DateUtil;
/**
* Description : TODO
* Create Time : 2013年11月28日 下午4:16:03
* Copyright : Copyright (c) 2010 - 2013 All rights reserved.
*
* @author Mr Yan
* @version 1.0
*/
@Component
public class TaskDemo {
/**
* 打印时间(每五秒打印一次)
*/
@Scheduled(cron="0/5 * * * * ?")
public void printTime(){
System.out.println(DateUtil.format(new Date(), "yyyyMMddHHmmss"));
}
}
2、配置applicationContext.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:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:task="http://www.springframework.org/schema/task"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-3.0.xsd">
<!-- 定时任务驱动注册(注解) -->
<task:annotation-driven />
</beans>
<?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:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">
<!-- load application context file -->
<import resource="applicationContext-task.xml"/>
</beans>
Spring3.X适用
- 大小: 57.9 KB
分享到:
相关推荐
1.精通Spring 4.x 企业应用开发实战精通Spring 4.x 企业应用开发实战精通Spring 4.x 企业应用开发实战精通Spring 4.x 企业应用开发实战精通Spring 4.x 企业应用开发实战精通Spring 4.x 企业应用开发实战精通Spring 4...
《Spring 3.x 企业应用开发实战》一书的部分lib包
Spring3.x企业应用开发实战(包括源码)绝对完整版 因未见太大,分8个小块(其他部分在本人资料里面查找),只有前4个每个收1分,后面4个免费下载,共4分,绝对完整,包含所有章节,不完整浏览分享
spring4.x
Spring 3.x+Spring MVC 3.x+MyBatis 3.x 整合代码 该代码仅截止到《Spring 3.x+Spring MVC 3.x+MyBatis 3.x 整合(五)MyBatis 3.2.5 整合》,原文件地址:http://blog.csdn.net/xz2001/article/details/44346355
《Spring 3.x企业应用开发实战》
spring4.x中的jar包下载,spring4.0.6下载,spring最新稳定版jar包下载 http://maven.springframework.org/release/org/springframework/spring/ 这个链接中有各种稳定版的jar包下载 目前官网上大部分都要maven下载
精通Spring 4.x 企业应用开发实战 陈雄华 PDF,清晰而且有标签,目录,非常好,谢谢分享。精通Spring 4.x 企业应用开发实战 陈雄华 PDF,清晰而且有标签,目录,非常好,谢谢分享。
Spring 3.x 企业应用开发实战 Spring 3.x 企业应用开发实战 Spring 3.x 企业应用开发实战 Spring 3.x 企业应用开发实战
有关spring注解方面的应用,很实用的,希望会帮助到有需要的people
丁振凡编著的《Spring3.x编程技术与应用》按 循序渐进的原则对Spring3.x的主要知识及应用体系 进行了较为系统的介绍,回答了应用开发者 最为关心的一些话题,目的是帮助读者快速理解和运用相关知识。 《Spring3.x...
Spring4.X教学视频,教会你如何一步一步搭建spring项目。
spring3.x源码 全面的SPRING3.X源代码 很全面 免费下
Spring3.x企业应用开发实战
《spring3.x企业应用开发实战》电子文档,对spring学习有帮助
Spring3.X编程技术与应用 Spring3.X编程技术与应用 Spring3.X编程技术与应用
精通Spring4.x企业应用开发实战pdf+源码,书和代码对的上呦
spring3.x完整版pdf,spring3.x书籍中所有的章节,如有帮助不胜感激
本书是在《精通Spring 3.x――企业应用开发详解》的基础上,历时一年的重大调整改版而成的,延续了上一版本“追求深度,注重原理,不停留在技术表面”的写作风格,力求使读者在熟练使用Spring的各项功能的同时透彻...
Spring3.x企业应用开发实战各个章节的光盘源码,可结合Spring3.x企业应用开发实战共同学习。