Error creating bean with name 'serverEndpointExporter' 因为websocket导致spring boot项目单元测试启动失败解决

项目问题:

博主在项目中引入了websocket功能主要作用于消息的推送,但是在进行其它方法Junit测试的时候发现出现如下错误

org.springframework.beans.factory.BeanCreationException: 
Error creating bean with name 'serverEndpointExporter' defined in class path resource

解决方案:

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
 
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
public class ApplicationTests {
 
	@Test
	public void contextLoads() {
	}
 
}

可以参考官方文档 https://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-testing.html  里面有详细说明

 

你可能感兴趣的:(Spring,Boot)