使用 Spring Boot 实现 WebSocket 服务端和网页客户端需要以下步骤:
在项目的 pom.xml 文件中添加 spring-boot-starter-websocket 依赖。
创建一个 WebSocketConfig 类,并使用 @EnableWebSocketMessageBroker 注解开启 WebSocket 消息代理。
在 WebSocketConfig 类中配置消息代理,可以使用 @Autowired 注入 SimpMessagingTemplate 类。
创建一个 WebSocketController 类,并使用 @Contr