java.lang.IllegalArgumentException: No 'javax.websocket.server.ServerContainer' ServletContext attribute. Are you running in a Servlet container that supports JSR-356?
将websocket的demo拉入自己的项目报错,其实显示的是web容器不包括这个JSR-356,
springboot自带的有tomcat,所以需要看下你更换的web容器,我换的是undertow容器,所以我的springboot启动类需要修改一下
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-websocket</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-undertow</artifactId>
</dependency>
这个问题我也是一脸懵逼,也找不到相同的,所以还是仔细观察才能解决bug。要仔细查看启动代码