前言
今天给我的毕业设计加上了自定义的 AOP
日志拦截,结果导致了 WebSocket
的报错。,错误信息为:
Failed to register @ServerEndpoint class: class pers.xuyijie.communityinteractionsystem.websocket.MyWebSocket$$EnhancerBySpringCGLIB
Caused by: javax.websocket.DeploymentException: Cannot deploy POJO class [pers.xuyijie.communityinteractionsystem.websocket.MyWebSocket$$EnhancerBySpringCGLIB
原因和解决方案
原因是因为 WebServerContainer
里面的 addEndPoint
方法里的 annotation
为 null。感谢 华阳余文乐https://blog.csdn.net/qq_15807785/article/details/83547978 ,上图是他的调试截图。
导致为 null 的原因是因为我们自定义的
aop
切面 影响到了@ServerEndpoint
,再具体的我也不懂,和动态代理有关了,总之,aop 不能作用到 websocket 的文件,否则就会导致问题。