GUNS项目 集成 WebSocket 踩到的坑
问题:运行项目时报如下错误
2021-12-10 16:20:24.614 ERROR 7280 --- [ main] o.s.boot.SpringApplication : Application run failed
java.lang.IllegalStateException: Failed to register @ServerEndpoint class: class cn.stylefeng.guns.modular.nakuservice.plugin.websocket.WebSocketService$$EnhancerBySpringCGLIB$$1986263b
at org.springframework.web.socket.server.standard.ServerEndpointExporter.registerEndpoint(ServerEndpointExporter.java:158)
at org.springframework.web.socket.server.standard.ServerEndpointExporter.registerEndpoints(ServerEndpointExporter.java:133)
at org.springframework.web.socket.server.standard.ServerEndpointExporter.afterSingletonsInstantiated(ServerEndpointExporter.java:111)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:862)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:877)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:549)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:140)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:742)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:389)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:311)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1213)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1202)
at cn.stylefeng.guns.GunsApplication.main(GunsApplication.java:36)
Caused by: javax.websocket.DeploymentException: Cannot deploy POJO class [cn.stylefeng.guns.modular.nakuservice.plugin.websocket.WebSocketService$$EnhancerBySpringCGLIB$$1986263b] as it is not annotated with @ServerEndpoint
at org.apache.tomcat.websocket.server.WsServerContainer.addEndpoint(WsServerContainer.java:220)
at org.springframework.web.socket.server.standard.ServerEndpointExporter.registerEndpoint(ServerEndpointExporter.java:155)
... 12 common frames omitted
我遇到的问题源自于项目本身的代理拦截机制,项目内置的拦截机制是: 我项目中写代码的包名如下 总结:我这里将包名nakuservice换一个不是service结尾的就好了,这千年难遇的巧合让我给碰上了,说多了都是泪(累)啊。
在我查资料的过程中,这位道友的解说很有参考价值:华阳余文乐
|