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:如果多个定时任务开启,需要配置线程池。

  • 相关阅读:
    数据库之联合查询和连接查询
    数据库要素 ER
    数据库事务
    关系数据库常用名词及解释
    数据库索引
    关于数据库主键和外键(终于弄懂啦)
    coredata 删除与更新
    Predicate Programming Guide
    NSPredicate
    coreData-Fetching Managed Objects
  • 原文地址:https://www.cnblogs.com/nnn123/p/6807772.html
Copyright © 2011-2022 走看看