首页 > 编程语言 > 详细

Springboot解决使用@Scheduled创建任务时无法在同一时间执行多个任务的BUG

时间:2019-12-24 19:02:08      阅读:463      评论:0      收藏:0      [点我收藏+]

1、在启动类使用

@SpringBootApplication
@EnableJpaRepositories(repositoryFactoryBeanClass = MyRepositoryFactoryBean.class)
@EnableTransactionManagement
@EnableAutoConfiguration
//@EnableAutoConfiguration(exclude = {org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration.class})
@EnableScheduling
@Configuration
@EnableDiscoveryClient
@EnableFeignClients
@EnableCaching
public class Application extends DefaultApplication {
    
    /**
     *
     *〈简述〉修复同一时间无法执行多个 定时任务问题
     *〈详细描述〉
     * @author miaoShijun
     * @return
     */
    @Bean
    public TaskScheduler taskScheduler() {
        ThreadPoolTaskScheduler taskScheduler = new ThreadPoolTaskScheduler();
        taskScheduler.setPoolSize(50);
        return taskScheduler;
    }
    
    /**
     * 〈简述〉应用启动入口
     * 〈详细描述〉
     *
     * @param args String[] 参数
     * @author miaoShijun
     */
    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
    }

}

 

Springboot解决使用@Scheduled创建任务时无法在同一时间执行多个任务的BUG

原文:https://www.cnblogs.com/miaosj/p/12092638.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!