springboot集成websocket启动异常信息


java.lang.IllegalStateException: Failed to register @ServerEndpoint class:

springboot集成websocket引用依赖


<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-websocket</artifactId> <version>2.1.2.RELEASE</version> </dependency>

原websocket服务类


@ServerEndpoint("socket/echo/{sid}") @Component public class WebSocketServer {…}

@ServerEndpoint 注解中配置路径必须以"/" 开头


@ServerEndpoint("/socket/echo/{sid}")

注:

使用tomcat
初始化构建websocket时,org.apache.tomact.websocket.service.UriTemplate
对path进行检验,必须以"/"开头。

Logo

一站式 AI 云服务平台

更多推荐