Springboot解決使用@Scheduled創建任務時無法在同一時間執行多個任務的BUG


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);
    }

}

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM