1、websocket 相關問題
1-1、javax.websocket.server.ServerContainer not available
經查閱資料,得知SpringBootTest在啓動的時候不會啓動服務器,所以WebSocket自然會報錯,這個時候需要添加選項webEnvironment,以便提供一個測試的web環境。如下:
@RunWith(SpringRunner.class) @SpringBootTest(classes = MyApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)