srpintBoot 项目单元测试启动报错 Error creating bean with name 'serverEndpointExporter'

srpintBoot 项目单元测试启动报错 Error creating bean with name 'serverEndpointExporter'

截图如下

srpintBoot 项目单元测试启动报错  Error creating bean with name 'serverEndpointExporter'

找到报错的代码

@Bean
    public ServerEndpointExporter serverEndpointExporter() {
        return new ServerEndpointExporter();
    }

发现是 new ServerEndpointExporter() 对象导致的,
原因是测试启动sprintBoot 项目没有开启服务器运行端口,导致 webSocket 服务无法启动
解决如下

 @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) 
上一篇:The Java™ Tutorials > Learning the Java Language > Classes and Objects > Objects > Creating Objects


下一篇:Error creating bean with name ‘articleController‘:Injection of autowired dependencies failed