MENU

SpringBoot单元测试:Failed to load ApplicationContext

December 17, 2020 • 默认分类

报错信息为:

Error creating bean with name 'serverEndpointExporter' defined in class path resource [com/imzcc/library/config/WebSocketConfig.class]: Invocation of init method failed; nested exception is java.lang.IllegalStateException: javax.websocket.server.ServerContainer not available

解决办法:
在SpringBootTest后加上:webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT

@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
Archives QR Code Tip
QR Code for this page
Tipping QR Code