问题描述:spring boot接入websocket时,启动报错:javax.websocket.server.ServerContainer not available
![](https://img2020.cnblogs.com/blog/491700/202101/491700-20210105153623943-1272293619.png)
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-websocket</artifactId>
</dependency>
原因:因为spring boot内带tomcat,tomcat中的websocket会有冲突。
解决办法:spring boot启动时排除tomcat依赖包即可:
<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-undertow</artifactId>
</dependency>