spring boot 运行测试类时:Error creating bean with name 'serverEndpointExporter' 问题
spring boot 运行测试类时:Error creating bean with name 'serverEndpointExporter' 问题 错误
前期测试类是好使的,突然就不好使了,开始找问题,最近我只是引入了webscoket,使用注解
@ServerEndpoint
就是这个注解惹得祸,
两种解决方式:
第一种:将@RunWith(SpringRunner.class) 去掉即可,但是这种方式会有局限,比如下方你要@Authwired一个类的时候会报错
第二种方式:
在SpringBootTest后加上
(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) 即可
原因:websocket是需要依赖tomcat等容器的启动。所以在测试过程中我们要真正的启动一个tomcat作为容器。