zoukankan      html  css  js  c++  java
  • spring3.0 定时器

    首先要引入xsd:

    <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"  

        xsi:schemaLocation="http://www.springframework.org/schema/beans   

       http://www.springframework.org/schema/beans/spring-beans-3.0.xsd  

        http://www.springframework.org/schema/task   

        http://www.springframework.org/schema/task/spring-task-3.0.xsd">  

      <!--    

    这里加入了  

    xmlns:task="http://www.springframework.org/schema/task"  

    http://www.springframework.org/schema/task   

        http://www.springframework.org/schema/task/spring-task-3.0.xsd  

      -->  

      <task:annotation-driven /> <!-- 定时器开关-->    

        <bean id="taskTest" class="com.jungle.test.TaskTest"></bean>    

        <task:scheduled-tasks>  

            <!--  这里表示的是从第五秒开始 ,每三秒执行一次 (而不是 三分之五 秒执行一次)  -->  

        <task:scheduled ref="taskTest" method="say" cron="5/3 * * * * ?" />  

       <task:scheduled ref="taskTest" method="hello" cron="5/3 * * * * ?"/>  

       </task:scheduled-tasks> 

    普通java类:

    package com.jungle.test;  

    import java.util.Date;  

    public class TaskTest {    

        public void say() {  

           System.out.println("这个真好用!!!" + new Date());  

        }    

       public void hello(){  

         System.out.println("hello!!!");  

        }  

    }  

  • 相关阅读:
    递归删除指定目录下的 .git 文件
    mina 字节数组编解码器的写法 I
    爬取大众点评
    使用Scrapy抓取数据
    Redis:默认配置文件redis.conf详解
    Redis:五种数据类型的简单增删改查
    使用python-docx生成Word文档
    IT部门域事件与业务分析
    因为说比做容易,所以要少说慎说
    主要问题
  • 原文地址:https://www.cnblogs.com/andyboy/p/3144234.html
Copyright © 2011-2022 走看看