springboot+vue实现websocket
1.引入依赖 <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-websocket</artifactId> <version>1.3.5.RELEASE</version> </dependency> 2.配置ServerEndpointExporter @Configuration public class WebSocketConfig { @Bean public ServerEndpointExporter serverEndpointExporter() { return new ServerEndpointExporter(); } } 这个bean会自动注册使用了@ServerEndpoint注解声明的Websocket endpoint。 3.创建websocket的ServerEndpoint端点 @Component @ServerEndpoint("/socket") public class WebSocketServer { /** * 全部在线会话 */ private static Map<String, Session> onlineSessions = new ConcurrentHashMap<>(); /** *