美文网首页
spring boot 实际应用(七) 定时任务

spring boot 实际应用(七) 定时任务

作者: 架构技术专栏 | 来源:发表于2017-08-30 18:34 被阅读25次

    定时任务采用注解的模式使用
    1、增加开启定时任务配置

    package com.ecej.meterread.task.base.config;  
    import org.springframework.context.annotation.Configuration;  
    import org.springframework.scheduling.annotation.EnableScheduling;  
    @Configuration  
    @EnableScheduling  
    public class SchedulConfig {  
    }  
    

    2、编写定时任务业务

    package com.ecej.meterread.task.base.run;  
    import org.springframework.scheduling.annotation.Scheduled;  
    import org.springframework.stereotype.Service;  
    @Service  
    public class Test {  
        @Scheduled(fixedRate = 50000)  
        public void testSchedul() {  
            System.out.println("Test Schedul ...");  
        }  
    }  
    

    关注公众号,将获得最新文章推送

    狍狍的日常生活

    相关文章

      网友评论

          本文标题:spring boot 实际应用(七) 定时任务

          本文链接:https://www.haomeiwen.com/subject/umuxjxtx.html