这篇文章主要介绍了spring boot定时任务的使用实例代码,需要的朋友可以参考下
Spring Boot中配置定时任务极其简单......下面看下实例代码:
本文档主要讲述的是SCA介绍及应用实例;SCA(Service Component Architecture)是针对SOA提出的一套服务体系构建框架协议,内部既融合了IOC的思想,同时又把面向对象的复用由代码复用上升到了业务模块组件复用,同时将服务接口,实现,部署,调用完全分离,通过配置的形式灵活的组装,绑定。希望本文档会给有需要的朋友带来帮助;感兴趣的朋友可以过来看看
0
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实现定时任务的java代码实例的详细内容,更多请关注php中文网其它相关文章!
java怎么学习?java怎么入门?java在哪学?java怎么学才快?不用担心,这里为大家提供了java速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号