美文网首页
springboot的@Scheduled问题

springboot的@Scheduled问题

作者: Pale_Eyes | 来源:发表于2019-04-26 19:13 被阅读0次

    网络参考:https://www.cnblogs.com/chyu/p/7801521.html

    import org.springframework.context.annotation.Bean;
    import org.springframework.context.annotation.Configuration;
    import org.springframework.scheduling.annotation.SchedulingConfigurer;
    import org.springframework.scheduling.config.ScheduledTaskRegistrar;
    
    import java.util.concurrent.Executor;
    import java.util.concurrent.Executors;
    
    @Configuration
    public class AppSchedulingConfigurer implements SchedulingConfigurer {
        @Override
        public void configureTasks(ScheduledTaskRegistrar taskRegistrar) {
            taskRegistrar.setScheduler(taskExecutor());
        }
    
        @Bean(destroyMethod="shutdown")
        public Executor taskExecutor() {
             return Executors.newScheduledThreadPool(10);
        }
    }
    

    相关文章

      网友评论

          本文标题:springboot的@Scheduled问题

          本文链接:https://www.haomeiwen.com/subject/pqoqnqtx.html