整合步骤很简单,请看下文分解。
<dependency>
<groupId>org.springframework.bootgroupId>
<artifactId>spring-boot-starter-websocketartifactId>
<version>2.3.3.RELEASEversion>
dependency>
package com.example.textMessageWebsocket;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.socket.config.annotation.EnableWebSocket;
import org.springframework.web.socket.config.annotation.WebSocketConfigurer;
import org.springframework.web.socket.config.annotation.WebSocketHandlerRegistry;
@Configuration
@EnableWebSocket
public class WebSocketTextMsgConfig implements WebSocketConfigurer {
@Autowired
WebSocketTextmsgHandler webSocketTextmsgHandler;
@Override
public void registerWebSocketHandlers(WebSocketHandlerRegistry registry