springBlade后端使用WebSocket,报错

Java 未结 7 6045
大神请教
大神请教 剑者 2020-02-21 22:38
org.springframework.bootspring-boot-starter-websocket


WebSocketConfig {

   ServerEndpointExporter () {
      ServerEndpointExporter()}
}

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'serverEndpointExporter' defined in class path resource [org/springblade/modules/lives/gongju/WebSocketConfig.class]: Invocation of init method failed; nested exception is java.lang.IllegalStateException: javax.websocket.server.ServerContainer not available


7条回答
  • 2021-10-21 11:22

            <dependency>

                <groupId>org.springframework.boot</groupId>

                <artifactId>spring-boot-starter-web</artifactId>

    <!--            <exclusions>-->

    <!--                <exclusion>-->

    <!--                    <groupId>org.springframework.boot</groupId>-->

    <!--                    <artifactId>spring-boot-starter-tomcat</artifactId>-->

    <!--                </exclusion>-->

    <!--            </exclusions>-->

            </dependency>

    <!--        <dependency>-->

    <!--            <groupId>org.springframework.boot</groupId>-->

    <!--            <artifactId>spring-boot-starter-undertow</artifactId>-->

    <!--        </dependency>-->


    我这边恢复了tomcat,去掉了undertow,解决了问题

    3 讨论(0)
  • 2020-08-12 13:48

    猜测原因:作者用的是undertow容器 你排除掉使用tomcat试试,我是这样解决的。


    1 讨论(0)
  •     <dependencies>

            <dependency>

                <groupId>org.springblade</groupId>

                <artifactId>blade-core-launch</artifactId>

            </dependency>

            <dependency>

                <groupId>org.springframework.boot</groupId>

                <artifactId>spring-boot-starter-websocket</artifactId>

            </dependency>

            <dependency>

                <groupId>org.springframework.boot</groupId>

                <artifactId>spring-boot-starter-amqp</artifactId>

            </dependency>

            <dependency>

                <groupId>org.springframework.boot</groupId>

                <artifactId>spring-boot-starter-reactor-netty</artifactId>

            </dependency>

        </dependencies>


    @Configuration

    @EnableWebSocketMessageBroker

    public class WebSocketConfig implements WebSocketMessageBrokerConfigurer {


    @Override

    public void registerStompEndpoints(StompEndpointRegistry registry) {

    registry.addEndpoint("/ws").withSockJS();

    }


    @Override

    public void configureMessageBroker(MessageBrokerRegistry registry) {

    registry.setApplicationDestinationPrefixes("/app");

    // Enables a simple in-memory broker

    registry.enableSimpleBroker("/topic");


    // Use this for enabling a Full featured broker like RabbitMQ

    /*registry.enableStompBrokerRelay("/topic")

    .setRelayHost("localhost")

    .setRelayPort(61613)

    .setClientLogin("guest")

    .setClientPasscode("guest");*/

    }

    }


    1 讨论(0)
  • 2020-03-12 17:32

    大佬,请问你解决了吗?


    0 讨论(0)
  • 2020-06-14 15:39

    同求,如何解决

    0 讨论(0)
  • 2020-07-03 15:23

    同问,如何解决

    0 讨论(0)
提交回复