SpringBoot
smile.red
生于忧患死于安乐
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
Springboot多线程定时任务
第一需要配置启动类注解开启定时任务功能(开启才可以使用)@EnableSchedulingpublic class Application {...}第二新建类AsyncConfig,代码如下import org.springframework.context.annotation.Bean;import org.springframework.context.annotation...原创 2019-01-18 16:14:40 · 1940 阅读 · 3 评论 -
负载项目中,定时任务同时执行解决方案
使用数据库改表数据解决, 比如将数据库中数据字段flag值0-初始,1-执行中,这样同一个程序被不同机器调用只会执行一次,代码如下 @Async @Scheduled(cron = "0 0 6 * * ?") public void abc() { String sql=" UPDATE table SET flag=1 WHERE id=?"; ...原创 2019-01-18 17:14:01 · 1148 阅读 · 0 评论
分享