springboot定时任务,比较简单!

1、编写DemoSchedule.java类

package com.rick.common.schedule;

import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled; import java.text.SimpleDateFormat;
import java.util.Calendar; /**
* Desc : 定时任务
* User : RICK
* Time : 2017/8/21 21:16
*/
@Configuration
@EnableScheduling
public class DemoSchedule { //cron表达式 秒分时 日月周 年
@Scheduled(cron = "0/10 * * * * ?") //每10秒执行一次
public void demoPrint(){
System.out.println("现在时间:" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(Calendar.getInstance().getTime()));
}
}

2、启动项目测试

3、项目清单

170627、springboot编程之定时任务的更多相关文章

  1. SpringBoot中的定时任务与Quartz的整合

    SpringBoot集成Quartz 定时任务Quartz : 就是在指定的时间执行一次或者循环执行,在项目的开发中有时候会需要的, 还是很有用的. SpringBoot内置的定时 添加依赖 < ...

  2. SpringBoot几种定时任务的实现方式

    定时任务实现的几种方式: Timer:这是java自带的java.util.Timer类,这个类允许你调度一个java.util.TimerTask任务.使用这种方式可以让你的程序按照某一个频度执行, ...

  3. springBoot中的定时任务

    springBoot中的定时任务 1:在Spring Boot的主类中加入@EnableScheduling注解,启用定时任务的配置 2:新建ScheduledTasks任务类 : package c ...

  4. SpringBoot中执行定时任务

    一:在SpringBoot中使用定时任务相当的简单.首先,我们在启动类中加入@EnableScheduling来开启定时任务. @SpringBootApplication @EnableSchedu ...

  5. springboot编程之全局异常捕获

    springboot编程之全局异常捕获 1.创建GlobalExceptionHandler.java,在类上注解@ControllerAdvice, 在方法上注解@ExceptionHandler( ...

  6. springboot整合@Scheduled定时任务的使用

    1.启动类里面添加注解@EnableScheduling ,例如: @SpringBootApplication@EnableScheduling@MapperScan("com.examp ...

  7. SpringBoot系列——动态定时任务

    前言 定时器是我们项目中经常会用到的,SpringBoot使用@Scheduled注解可以快速启用一个简单的定时器(详情请看我们之前的博客<SpringBoot系列--定时器>),然而这种 ...

  8. Springboot的默认定时任务——Scheduled注解

    本博客参考博文地址. 1.pom依赖: 引入springboot starter包即可 <dependencies> <dependency> <groupId>o ...

  9. 在SpringBoot中配置定时任务

    前言 之前在spring中使用过定时任务,使用注解的方式配置很方便,在SpringBoot中的配置基本相同,只是原来在spring中的xml文件的一些配置需要改变,在SpringBoot中也非常简单. ...

随机推荐

  1. Geometric deep learning on graphs and manifolds using mixture model CNNs

    Monti, Federico, et al. "Geometric deep learning on graphs and manifolds using mixture model CN ...

  2. awk基础命令

    1. 命令awk简介 a. awk是一种编程语言,用于对文本和数据进行处理. b.具有强大得文本格式话能力 c.利用命令awk,可以将一些文本整理成需要的格式. d.命令awk是逐行进行处理的 2. ...

  3. 【转】【C++】C++ 中的线程、锁和条件变量

    线程 类std::thread代表一个可执行线程,使用时必须包含头文件<thread>.std::thread可以和普通函数,匿名函数和仿函数(一个实现了operator()函数的类)一同 ...

  4. (转)platform_driver_register,什么时候调用PROBE函数 注册后如何找到驱动匹配的设备

     platform_driver_register,什么时候调用PROBE函数 注册后如何找到驱动匹配的设备 2011-10-24 19:47:07 分类: LINUX   kernel_init中d ...

  5. smrt analysis 软件安装

    pacbio 公司把三代测序常用软件整合起来,做成了一个在线的分析软件,类似于galaxy; 安装过程如下,参考官网给的指导手册 http://www.pacb.com/wp-content/uplo ...

  6. path与classpath的差别

    1.path的作用     path是系统用来指定可运行文件的完整路径.即使不在path中设置JDK的路径也可运行JAVA文件,但必须把完整的路径写出来,如C:\Program Files\Java\ ...

  7. 第五章 使用 SqlSession(MyBatis)

    在 MyBatis 中,你可以使用 SqlSessionFactory 来创建 SqlSession.一旦你获得一个 session 之后,你可以使用它来执行映射语句,提交或回滚连接,最后,当不再需要 ...

  8. C语言对文件的操作函数用法详解2

    fopen(打开文件) 相关函数 open,fclose 表头文件 #include<stdio.h> 定义函数 FILE * fopen(const char * path,const  ...

  9. webBrowser 模拟登录

    webBrowser1.Document.GetElementById("txtUsername").InnerText = "sdsy";//fill nam ...

  10. PL/SQL如何调试Oracle存储过程

    from:http://jingyan.baidu.com/article/3a2f7c2e144d2826aed61167.html 调试过程对找到一个存过的bug或错误是非常重要的,Oracle作 ...