当前位置:   article > 正文

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

error creating bean with name 'serverendpointexporter

项目问题:

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

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

解决方案:

  1. import org.junit.Test;
  2. import org.junit.runner.RunWith;
  3. import org.springframework.boot.test.context.SpringBootTest;
  4. import org.springframework.test.context.junit4.SpringRunner;
  5. @RunWith(SpringRunner.class)
  6. @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
  7. public class ApplicationTests {
  8. @Test
  9. public void contextLoads() {
  10. }
  11. }

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

 

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Gausst松鼠会/article/detail/733957
推荐阅读
相关标签
  

闽ICP备14008679号