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触发

  • 相关阅读:
    Oracle SQL语句收集
    SqlParameter In 查询
    SQL 性能优化
    Entity Framework
    【XLL API 函数】 xlfSetName
    【XLL API 函数】xlfUnregister (Form 2)
    【XLL API 函数】xlfUnregister (Form 1)
    【Excel 4.0 函数】REGISTER 的两种形式以及VBA等效语句
    【Excel 4.0 函数】REGISTER
    【Bochs 官方手册翻译】 第一章 Bochs介绍
  • 原文地址:https://www.cnblogs.com/god-monk/p/6519359.html
Copyright © 2011-2022 走看看