@SpringBootTest在引入websocket后异常

@SpringBootTest在引入websocket后

 

@Configuration
public class WebSocketConfig {


    @Bean
    public ServerEndpointExporter serverEndpointExport() {
        
        return new ServerEndpointExporter();
    }
}

原因是websocket需要tomcat来暴露端口,但是@Test没有独立的servlet,解决方式是

@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
posted @ 2022-01-07 11:33  jason47  阅读(207)  评论(0编辑  收藏  举报