Spring Boot 集成 websocket(广播式)遇到的方法过时及解决方法

书上配置WebSocket的方法在springboot2.x已经过时

在1.x版本中写法如下:

@Configuration
@EnableWebSocketMessageBroker//1
public class WebSocketConfig extends AbstractWebSocketMessageBrokerConfigurer{
}

在2.x之后改为:

@Configuration

@EnableWebSocket

public class WebSocketConfig implements WebSocketMessageBrokerConfigurer {

}

 

在SpringBoot2.0及Spring 5.0 WebMvcConfigurerAdapter已被废弃,目前找到解决方案就有两种

旧:@Configuration
public class WebMvcConfig extends WebMvcConfigurerAdapter{}

新方法@Configuration public class WebMvcConfg implements WebMvcConfigurer {

//todo

}

@Configuration public class WebMvcConfg extends WebMvcConfigurationSupport {

//todo

}

posted @ 2019-08-16 11:23  薄情的树先生  阅读(793)  评论(0编辑  收藏  举报