SpringBoot报错Action: Consider defining a bean named 'webMvcAsyncTaskExecutor' in your configuration

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/zhouxianling233/article/details/83111629

前言:

往SpringBoot2.0项目中,加入webSocket,往config中加入注解@EnableWebSocketMessageBroker,项目无法启动,报错如下:

Action: Consider defining a bean named 'webMvcAsyncTaskExecutor' in your configuration。

解决方法:

在你的Application加入,如下配置,再起启动,就启动起来了.

@SpringBootApplication
public class WsApplication {

    public static void main(String[] args) {
        SpringApplication.run(WsApplication.class, args);
    }
	
	//加入如下配置
    @Bean({"threadPoolTaskExecutor", "webMvcAsyncTaskExecutor"})
    public ThreadPoolTaskExecutor threadPoolTaskExecutor() {
        return new ThreadPoolTaskExecutor();
    }
}

猜你喜欢

转载自blog.csdn.net/zhouxianling233/article/details/83111629
今日推荐