spring-guides / gs-messaging-stomp-websocket

Using WebSocket to build an interactive web application :: Learn how to the send and receive messages between a browser and the server over a WebSocket
http://spring.io/guides/gs/messaging-stomp-websocket/
Apache License 2.0
530 stars 474 forks source link

Caused by: java.lang.NoClassDefFoundError: org/springframework/web/socket/client/WebSocketClient #67

Closed monxarat closed 4 years ago

monxarat commented 4 years ago

Please help me.

@EnableWebSocketMessageBroker
@Service
public class QuotesSocket {

    @Value("${app.quotes.socket.url}")
    private String url;
    private Logger logger = LogManager.getLogger(QuotesStompSessionHandler.class);

    WebSocketStompClient webSocketStompClient;

    @PostConstruct
    public void connect() {
        WebSocketClient client = new StandardWebSocketClient();
        webSocketStompClient = new WebSocketStompClient(client);
        webSocketStompClient.setMessageConverter(new MappingJackson2MessageConverter());
        StompSessionHandler sessionHandler = new QuotesStompSessionHandler();
        webSocketStompClient.connect(url, sessionHandler);

        new Scanner(System.in).nextLine();
    }
@EnableWebSocket
public class WebSocketConfig implements WebSocketConfigurer {

    @Override
    public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {

    }

}
dsyer commented 4 years ago

WebSocketClient is in spring-webflux. I guess you forgot to include a dependency? Is this relevant to the guide? I'm guessing not, but if you think it is just squawk and we can dig into it more.