报错信息:
Error creating bean with name ‘serverEndpointExporter’ defined in
class path resource [com/jcagv/ivp/config/WebSocketConfig.class]:
Invocation of init method failed; nested exception is
java.lang.IllegalStateException:
javax.websocket.server.ServerContainer not available
报错原因:@SpringBootTest 做单元测试时不会启动服务器,导致websocket报错
解决办法:
在@SpringBootTest后加
(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)