springboot定时任务出错 Unexpected use of scheduler.

java.lang.IllegalStateException: Unexpected use of scheduler.

在启动类加:

@Bean
    public ThreadPoolTaskScheduler taskScheduler(){
        ThreadPoolTaskScheduler taskScheduler = new ThreadPoolTaskScheduler();
        taskScheduler.setPoolSize(10);
        taskScheduler.initialize();
        return taskScheduler;
    }

 

posted on 2019-06-12 19:09  james-roger  阅读(1808)  评论(0编辑  收藏  举报