Spring Boot定时任务的使用方法
投稿:lijiao
这篇文章为大家详细主要介绍了Spring Boot定时任务的使用方法,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
本文介绍在Spring Boot 中如何使用定时任务,使用非常简单,就不做过多说明了。
下面是代码类:
package org.springboot.sample.config; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.context.annotation.Configuration; import org.springframework.scheduling.annotation.EnableScheduling; import org.springframework.scheduling.annotation.Scheduled; /** * 定时任务配置类 * * @author 单红宇(365384722) * @myblog http://blog.csdn.net/catoop/ * @create 2016年3月21日 */ @Configuration @EnableScheduling // 启用定时任务 public class SchedulingConfig { private final Logger logger = LoggerFactory.getLogger(getClass()); @Scheduled(cron = "0/20 * * * * ?") // 每20秒执行一次 public void scheduler() { logger.info(">>>>>>>>>>>>> scheduled ... "); } }
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持脚本之家。
您可能感兴趣的文章:
- SpringBoot定时任务两种(Spring Schedule 与 Quartz 整合 )实现方法
- 详解SpringBoot 创建定时任务(配合数据库动态执行)
- 详解Spring Boot中使用@Scheduled创建定时任务
- spring-boot通过@Scheduled配置定时任务及定时任务@Scheduled注解的方法
- 详解Spring Boot 定时任务的实现方法
- SpringBoot 定时任务遇到的坑
- springboot整合Quartz实现动态配置定时任务的方法
- springboot整合quartz实现定时任务示例
- spring boot整合quartz实现多个定时任务的方法
- 详解SpringBoot定时任务说明