• Context initialization failed org.springframework.beans.factory.BeanCreationException


    严重: Context initialization failed 
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘webSocketHandlerMapping’ defined in class path resource [org/springframework/web/socket/config/annotation/DelegatingWebSocketConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.web.servlet.HandlerMapping]: Factory method ‘webSocketHandlerMapping’ threw exception; nested exception is java.lang.IllegalStateException: No suitable default RequestUpgradeStrategy found 
    at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:599) 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1111) 
    at … 
    Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.web.servlet.HandlerMapping]: Factory method ‘webSocketHandlerMapping’ threw exception; nested exception is java.lang.IllegalStateException: No suitable default RequestUpgradeStrategy found 
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:189) 
    at … 
    Caused by: java.lang.IllegalStateException: No suitable default RequestUpgradeStrategy found 
    at org.springframework.web.socket.server.support.DefaultHandshakeHandler.initRequestUpgradeStrategy(DefaultHandshakeHandler.java:127) 
    at …

    出现上述异常,是由于缺少RequestUpgradeStrategy 
    对于jetty,需要添加如下依赖

    1     <dependency>
    2         <groupId>org.eclipse.jetty.websocket</groupId>
    3         <artifactId>websocket-server</artifactId>
    4         <version>9.3.3.v20150827</version>
    5         <scope>provided</scope>
    6     </dependency>

    对于tomcat,需要添加如下依赖

        <dependency>
            <groupId>org.apache.tomcat.embed</groupId>
            <artifactId>tomcat-embed-websocket</artifactId>
            <version>8.0.23</version>
            <scope>provided</scope>
        </dependency>

    在poem.xml文件中添加这两个依赖后成功解决

    原文:https://blog.csdn.net/manerfan/article/details/48526681 
    来源:CSDN

  • 相关阅读:
    Visual Studio提示“无法启动IIS Express Web服务器”的解决方法
    两种为wangEditor添加拖拽调整高度的方式:CSS3和jQuery UI
    使用JavaScript把页面上的表格导出为Excel文件
    UEditor的jQuery插件化
    wangEditor的jQuery插件化
    使元素相对于窗口或父元素水平垂直居中的几种方法
    在ASP.NET Web Forms中使用页面导出伪xls Excel表格
    全表对比增量抽取
    Kettle日常使用汇总整理
    maven项目的标准目录结构
  • 原文地址:https://www.cnblogs.com/keenoooo/p/10235593.html
Copyright © 2020-2023  润新知