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!!!");  

        }  

    }  

  • 相关阅读:
    16.什么是面向对象编程?
    15.运动
    14.this指向和ES6常用内容
    13.正则表达式
    12.事件模型
    11.event事件对象
    10.BOM
    9.DOM
    拓扑排序学习(复习)笔记
    [Luogu] P1987 摇钱树
  • 原文地址:https://www.cnblogs.com/andyboy/p/3144234.html
Copyright © 2011-2022 走看看