springboot启动抛出javax.websocket.server.ServerContainer not available


问题描述:spring boot接入websocket时,启动报错:javax.websocket.server.ServerContainer not available
<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>
 
posted @ 2021-01-05 15:39  幸运星~  阅读(8113)  评论(0编辑  收藏  举报