springboot 2.0.5集成websocket错误

时间:2018-09-20 03:41:49

标签: java spring websocket

enter image description here

enter image description here

控制台错误:

  

启动ApplicationContext时出错。要显示条件报告,请在启用“调试”的情况下重新运行您的应用程序。   11:36:58 spring-boot [main]错误o.s.boot.SpringApplication-应用程序运行失败   java.lang.IllegalStateException:无法注册@ServerEndpoint类:com.simple.springbootbasic.basic.websocket.WebSocketServer $$ EnhancerBySpringCGLIB $$ 50508009类       在org.springframework.web.socket.server.standard.ServerEndpointExporter.registerEndpoint(ServerEndpointExporter.java:158)       在org.springframework.web.socket.server.standard.ServerEndpointExporter.registerEndpoints(ServerEndpointExporter.java:133)       在org.springframework.web.socket.server.standard.ServerEndpointExporter.afterSingletonsInstantiated(ServerEndpointExporter.java:111)       在org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:776)       在org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:869)       在org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:550)       在org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:140)       在org.springframework.boot.SpringApplication.refresh(SpringApplication.java:780)       在org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:412)       在org.springframework.boot.SpringApplication.run(SpringApplication.java:333)       在org.springframework.boot.SpringApplication.run(SpringApplication.java:1277)       在org.springframework.boot.SpringApplication.run(SpringApplication.java:1265)       在com.simple.springbootbasic.Application.main(Application.java:19)   原因:javax.websocket.DeploymentException:无法部署POJO类[com.simple.springbootbasic.basic.websocket.WebSocketServer $$ EnhancerBySpringCGLIB $$ 50508009],因为它未使用@ServerEndpoint进行注释       在org.apache.tomcat.websocket.server.WsServerContainer.addEndpoint(WsServerContainer.java:203)       在org.springframework.web.socket.server.standard.ServerEndpointExporter.registerEndpoint(ServerEndpointExporter.java:155)       ...省略了12个通用框架   11:36:58 spring-boot [main]信息o.s.b.w.s.c.AnnotationConfigServletWebServerApplicationContext-关闭org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@72ea6193:启动日期[Chu Sep 20 11:36:53 CST 2018];上下文层次结构的根   11:36:58 spring-boot [main] INFO o.s.j.e.a.AnnotationMBeanExporter-关机时注销JMX暴露的bean   11:36:58 spring-boot [main]信息c.alibaba.druid.pool.DruidDataSource-{dataSource-1}已关闭   与目标VM断开连接,地址:“ 127.0.0.1:2440”,传输:“套接字”

以退出代码1完成的过程

1 个答案:

答案 0 :(得分:0)

我不知道您的项目包含什么,但是当我有两个都用@ServerEndpoint注释的类时,我在自己的项目中遇到了相同的错误。每个项目只能有一个端点,因此,如果您的项目包含两个都用@ServerEndpoint注释的类,只需从其中一个类中删除@ServerEndpoint注释。

相关问题