zoukankan      html  css  js  c++  java
  • spring scheduled

    <?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:task="http://www.springframework.org/schema/task"
        xmlns:context="http://www.springframework.org/schema/context"
        xsi:schemaLocation="http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-4.1.xsd
            http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
            http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.1.xsd">
      <!--task任务扫描注解-->
        <task:annotation-driven/>

      <!--扫描包位置-->
        <context:component-scan base-package="cn.anosi.task"/>  
    </beans>

    package cn.anosi.task;

    import org.slf4j.Logger;
    import org.slf4j.LoggerFactory;
    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.scheduling.annotation.Scheduled;
    import org.springframework.stereotype.Component;

    import cn.anosi.service.wa.WaRefundService;

    @Component
    public class WaTask {
        @Autowired
        private WaRefundService waRefundService;
        
        protected Logger logger = LoggerFactory.getLogger(getClass().getName());

        @Scheduled(cron="0 0 0 * * ?")   //每天零点执行一次  
        public void deletePartspack()throws Exception{  
            int back=waRefundService.delete();
            logger.debug("定时删除wa_partspack表"+back+"条无效数据!");
        }
    }

    定时器任中方法务没有返回值

    "0 0 12 * * ?"        每天中午十二点触发 
    "0 15 10 ? * *"        每天早上10:15触发 
    "0 15 10 * * ?"          每天早上10:15触发 
    "0 15 10 * * ? *"       每天早上10:15触发 
    "0 15 10 * * ? 2005"      2005年的每天早上10:15触发 
    "0 * 14 * * ?"        每天从下午2点开始到2点59分每分钟一次触发 
    "0 0/5 14 * * ?"       每天从下午2点开始到2:55分结束每5分钟一次触发 
    "0 0/5 14,18 * * ?"    每天的下午2点至2:55和6点至6点55分两个时间段内每5分钟一次触发 
    "0 0-5 14 * * ?"       每天14:00至14:05每分钟一次触发 
    "0 10,44 14 ? 3 WED"     三月的每周三的14:10和14:44触发 
    "0 15 10 ? * MON-FRI"  每个周一、周二、周三、周四、周五的10:15触发

  • 相关阅读:
    树莓派配置
    《C#微信开发系列(Top)-微信开发完整学习路线》
    Git基础使用教程(仓库初始化,源码clone,源码push)
    《Cron表达式详解》
    《CSS实现单行、多行文本溢出显示省略号》
    《C#多线程编程实现方式》
    《SQLServer删除重复数据的方法》
    《java提高数据导入效率优化思路》
    《如何使用Javascript判断浏览器终端设备》
    《动手实现一个网页加载进度loading》
  • 原文地址:https://www.cnblogs.com/god-monk/p/6519359.html
Copyright © 2011-2022 走看看