栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

SpringBoot 集成 WebSocket 遇到的问题 java.lang.IllegalStateException: Failed to register @ServerEndpoint

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

SpringBoot 集成 WebSocket 遇到的问题 java.lang.IllegalStateException: Failed to register @ServerEndpoint

websocket server代码如下:


@Slf4j
@Component
@ServerEndpoint(value = "/websocket/{type}")
public class WebSocketServer {

    ……
}

错误如下: 

java.lang.IllegalStateException: Failed to register @ServerEndpoint class: class com.test.websocket.WebSocketServer$$EnhancerBySpringCGLIB$$31689f61
 
javax.websocket.DeploymentException: Cannot deploy POJO class [com.xxx.WebSocketServer$$EnhancerBySpringCGLIB$$31689f61] as it is not annotated with @ServerEndpoint

后面那一串是代表类被CGLIB转换为了代理对象,什么情况下会被转换为代理对象?

AOP!

AOP!

AOP!

WebSocketServer这个类被切了,以至于@ServerEndPoint注解无法注入至对应的对象,导致报错;检查自己项目中的AOP切入点,包括springboot配置文件里的,排除掉 WebSocketServer不被切就可以了。

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/671821.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号