zoukankan      html  css  js  c++  java
  • spring定时器

    1.spring的定时器功能,

    //==============================================
    //执行类,每五秒执行一次

    @Service
    @EnableScheduling
    public class TimerTest {
        
        @Scheduled(cron="0/5 * * * * ?")
        public void run(){
            System.out.println("定时器。。。。。。。。。");
        }
    }

    //==============================================
    //在spring主配置文件(applicationContext.xml<可能会改名字,配置aop、tx的xml>)中,进行配置
      

     1> 约束声明
            xmlns:task="http://www.springframework.org/schema/task"
            xsi:schemaLocation= "http://www.springframework.org/schema/task
            http://www.springframework.org/schema/task/spring-task.xsd"
        2> 开启@Scheduled注解支持
            <task:annotation-driven />
            
        也可进行非注解的方式进行,两者均可,都可进行参数配置
        
    //==================================================
    详细内容参见(转): http://blog.csdn.net/qq_33556185/article/details/51852537
    //===================================================
    tips:如果多个定时任务开启,需要配置线程池。

  • 相关阅读:
    c11---位运算相关
    c10---多文件开发
    C9---include,编译
    c8---递归
    c7---函数
    c6----函数的声明和实现
    c5
    Arm 环境上面libgdiplus的简单安装配置
    批量查找可执行文件目录的简单方法
    Android常用工具类
  • 原文地址:https://www.cnblogs.com/nnn123/p/6807772.html
Copyright © 2011-2022 走看看