zoukankan      html  css  js  c++  java
  • SpringBoot项目测试类报错: Error creating bean with name 'serverEndpointExporter' defined in class path resource ...

    异常 :

    Error creating bean with name 'serverEndpointExporter' defined in class path resource [com/zjxf/config/web/WebSocketConfig.class]: Invocation of init method failed; nested exception is java.lang.IllegalStateException: javax.websocket.server.ServerContainer not available
    

    解决方法:
    引入:

    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-test</artifactId>
    </dependency>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-websocket</artifactId>
    </dependency>
    

    在SpringBootTest注解中添加webEnvironment配置:

    @RunWith(SpringRunner.class)
    @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
    

    参考博客: https://www.jianshu.com/p/bac3aa8cdc02

  • 相关阅读:
    B
    F
    递推,大数存储E
    为什么感觉一无所获
    java new synchronized
    Java Phaser
    java Semaphore
    java Exchanger 2
    JAVA Exchanger
    java CyclicBarrier 2
  • 原文地址:https://www.cnblogs.com/wqkeep/p/13474254.html
Copyright © 2011-2022 走看看