spring boot中配置定时任务极其简单......下面看下实例代码:
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.date; /** * created by winner_0715 on 2017/4/18. */ @configuration @enablescheduling public class schedulingconfig { // 每5秒执行一次 @scheduled(cron = "0/5 * * * * ?") public void scheduler() { system.out.println("schedulingconfig.scheduler()" + new simpledateformat("yyyy-mm-dd hh:mm:ss").format(new date())); } }
以上所述是小编给大家介绍的spring boot定时任务的使用实例代码,希望对大家有所帮助
如对本文有疑问, 点击进行留言回复!!
利用python将Mysql信息以Excel文件并作为邮件附件发送
springmvc+mybaits+mysql上传表情Incorrect string value: ‘\xF0\x9F\xA4\xB4\xF0\x9F...‘ for
SpringCloud Greenwich集成Seata1.2.0详解说明(原创by ulwfcyvi)
mybatis generator生成代码库 与指定的库不一致 为其他库的同名表
网友评论