单元测试在没有集成websocket之前是好好的,当集成websocket之后就出现了下面的异常(只贴出来关键信息):

2019-01-11 10:05:42 [ERROR] [org.springframework.boot.SpringApplication:858] - Application run failed 
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'serverEndpointExporter' defined in class path resource [com
Caused by: java.lang.IllegalStateException: javax.websocket.server.ServerContainer not available

个人猜想异常原因就是因为@ServerEndpoint注解引起的

于是在单元测试上面添加了下面的注解就可以运行了:

@SpringBootTest(classes = {Application.class}, webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT)

Application个类就是程序的入口类。在此做一下记录

相关文章:

  • 2022-12-23
  • 2021-10-09
  • 2021-11-07
  • 2021-10-29
  • 2021-07-10
  • 2021-06-13
  • 2021-12-15
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-07-07
  • 2022-12-23
  • 2021-04-07
  • 2022-12-23
  • 2021-08-22
相关资源
相似解决方案