zoukankan      html  css  js  c++  java
  • springMvc 添加定时任务

    1、创建定时类

    import org.springframework.scheduling.annotation.Scheduled;
    import org.springframework.stereotype.Component;
    
    @Component
    public class FlightTrainTask {
        @Scheduled(cron = "0/5 * * * * ? ") // 间隔5秒执行
        public void taskCycle() {
            System.out.println("使用SpringMVC框架配置定时任务");
        }
    }
    

      

    2、在spring的配置xml文件中开启定时选项

    <task:annotation-driven />
    <context:component-scan base-package="com.timer" />  //定时器所在文包
    

      

  • 相关阅读:
    Tye exception
    DataSeeder
    angular
    认证Authentication
    MVC
    Ef Core
    工作单元
    VirtualFileSystem
    中间件
    日志
  • 原文地址:https://www.cnblogs.com/cyrfr/p/9274314.html
Copyright © 2011-2022 走看看