SpringBoot整合webSocket出现Are you running in a Servlet container that supports JSR-356?

如果你使用的是SpringBoot自带的tomcat出现这种问题 那么换成别的容器就行了。

首先要将已经存在的容器排除掉 使用 exclusions 排除容器依赖 然后再添加别的容器依赖

比如

<dependency> 
    <groupId>org.springframework.boot</groupId> 
    <artifactId>spring-boot-starter-undertow</artifactId> 
</dependency>

如果你使用的恰好是undertow这个容器 那么换成tomcat容器试试

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-tomcat</artifactId>
</dependency>

我自己整合的时候没有出现过这种问题,但是使用开源框架的时候出现了这种问题,

经过排查发现作者使用的是undertow容器。

参考文章:

https://blog.csdn.net/nuoyuezuo/article/details/105664474

https://www.cnblogs.com/ZMargo/articles/13364594.html

原文地址:https://www.cnblogs.com/yang-xiansen/p/13490269.html