tomcat部署WebSocket服务,初始化ServerEndPointExporter失败问题
参考 原文链接:https://blog.csdn.net/weixin_40936211/article/details/89466144
在spring boot单元测试的时候会遇到很多问题,我在使用websocket的时候会运行测试类,报错: Error creating bean with name ‘serverEndpointExporter’ defined in class path resource
在SpringBootTest后加上:webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT,意思是创建Web应用程序上下文(基于响应或基于servlet),原因:websocket是需要依赖tomcat等容器的启动。所以在测试过程中我们要真正的启动一个tomcat作为容器。