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。要仔細查看啓動代碼