使用WebSocket导致jUnit单元测试报No suitable default RequestUpgradeStrategy found错误的解决方法

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_33223299/article/details/87971229

若在SpringMVC项目中使用了WebSocket,在运行jUnit单元测试时,可能会报如下错误:

Caused by: java.lang.IllegalStateException: No suitable default RequestUpgradeStrategy found

若出现上述异常,在Maven的pom.xml中添加如下依赖,问题即可解决:

<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-websocket</artifactId>
<version>7.0.52</version>
<scope>test</scope>
</dependency>

猜你喜欢

转载自blog.csdn.net/qq_33223299/article/details/87971229