Spring websocket in existing project- not working

北城以北 提交于 2019-12-11 13:27:24

问题


I have an existing project in Spring MVC which works as expected without any issues. Iam able to take view pages via controller.

Now i configure spring websocket into this existing project using below code

@Configuration
@EnableWebSocketMessageBroker
public class WebSocketConfig extends AbstractWebSocketMessageBrokerConfigurer {

    @Override
    public void configureMessageBroker(MessageBrokerRegistry config) {
        config.enableSimpleBroker("/topic");
        config.setApplicationDestinationPrefixes("/app");
    }


    public void registerStompEndpoints(StompEndpointRegistry registry) {
        registry.addEndpoint("/gs-guide-websocket").withSockJS();
    }

}

Maven dependencies added mentioned below

<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-websocket</artifactId>
    <version>4.3.11.RELEASE</version>
</dependency>


<!-- https://mvnrepository.com/artifact/org.springframework/spring-messaging -->
<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-messaging</artifactId>
    <version>4.0.0.RELEASE</version>
</dependency>

This is the only thing i have done, after this my app is not working. When i take url-localhost:8080/myapp am not able to see my view. When i comment websocket configuration class everything works fine.

No error in app or server log- Any clue please !?

来源:https://stackoverflow.com/questions/47277160/spring-websocket-in-existing-project-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!