时间: 2020-08-24|13次围观|0 条评论

开发环境

idea2016

jdk1.8

win7

新建项目

按下图操作:

spring boot 整合定时任务插图
spring boot 整合定时任务插图1
spring boot 整合定时任务插图2
spring boot 整合定时任务插图3
spring boot 整合定时任务插图4
打卡pom.xml,添加以下依赖

<dependency>  

 <groupId>org.quartz-scheduler

  <artifactId>quartz

  <version>2.2.1

        <artifactId>slf4j-api

        <groupId>org.slf4j

</dependency>

spring boot 整合定时任务插图5
新建TaskJob类,代码如下

spring boot 整合定时任务插图6
cron表达式输入你要执行的时间,启动项目看是否成功

spring boot 整合定时任务插图7
如图所示已经输出了this is task job!定时任务就这么简单

文章转载于:https://www.jianshu.com/p/c725b1e4265e

原著是一个有趣的人,若有侵权,请通知删除

本博客所有文章如无特别注明均为原创。
复制或转载请以超链接形式注明转自起风了,原文地址《spring boot 整合定时任务
   

还没有人抢沙发呢~