声明一点,使用的WebSocket是Spring集成的,属于spring-websocket。在Junit测试过程中报错,刚开始照网上添加Jetty的jar包方法,添加了一个
<dependency>
<groupId>org.eclipse.jetty.websocket</groupId>
<artifactId>websocket-client</artifactId>
<version>9.3.4.RC0</version>
<!--<scope>test</scope>-->
</dependency>
<dependency>
<groupId>org.eclipse.jetty.websocket</groupId>
<artifactId>websocket-server</artifactId>
<version>9.3.4.RC0</version>
<!--<scope>test</scope>-->
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-client</artifactId>
<version>9.3.4.RC0</version>
<!--<scope>test</scope>-->
</dependency>
发现没有效果,反倒是引发了其他问题,后来在StackOverFlow看到如下方法,不引入上述的jar包,而是只引入下面一个
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-websocket</artifactId>
<version>8.5.15</version>
</dependency>
至此,问题解决