zoukankan      html  css  js  c++  java
  • springboot quartz 注解的最简单使用

    依赖:

    <!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-quartz -->
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-quartz</artifactId>
        <version>2.1.0.RELEASE</version>
    </dependency>

    定时任务: 项目中无其他任何其他配置

    定时方法:

    import org.springframework.scheduling.annotation.EnableScheduling;
    import org.springframework.scheduling.annotation.Scheduled;
    import org.springframework.stereotype.Component;
    
    @Component
    @EnableScheduling
    public class QuertzTest {
        
        @Scheduled(cron = "0/2 * * * * ?")
        public void testimer() {
            System.err.println("#########");
            System.err.println("#########");
            System.err.println("#########");
            System.err.println("#########");
            System.err.println("#########");
        }
        
    
    }

    结果:一直输出:

    #########
    #########
    #########
    #########
    #########

  • 相关阅读:
    4.一对多关联映射
    3.一对一关联映射
    1.Hibernate框架
    19。数据库技术及分页
    18.文件的上传和下载
    17.JavaMail
    16.部署描述符文件
    15.Servlet程序结构与部署
    dba-查询sql耗时
    (72)C# 特性
  • 原文地址:https://www.cnblogs.com/lshan/p/11169009.html
Copyright © 2011-2022 走看看