Spring Boot定时任务的使用实例代码
程序员文章站
2024-02-28 15:01:22
spring boot中配置定时任务极其简单......下面看下实例代码:
import org.springframework.context.annotati...
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定时任务的使用实例代码,希望对大家有所帮助