Spring 4 MVC和Websockets - 没有合适的默认RequestUpgradeStrategy [英] Spring 4 MVC and Websockets - No suitable default RequestUpgradeStrategy

查看:145
本文介绍了Spring 4 MVC和Websockets - 没有合适的默认RequestUpgradeStrategy的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序需要Websockets进行实时更新。所以我找到了这个例子并且一步一步做了此处


  org.springframework .beans.factory.BeanCreationException:创建名称为

'org.springframework.web.socket的bean时出错。 server.support.DefaultHandshakeHandler#0':
bean的实例化失败;嵌套的异常是
org.springframework.beans.BeanInstantiationException:不能
实例化bean类
[org.springframework.web.socket.server.support.DefaultHandshakeHandler]:
构造函数抛出例外;嵌套异常是
java.lang.IllegalStateException:没有合适的默认值
找到RequestUpgradeStrategy

我搜索了很多,但我没有找到解决方案。

我希望任何人都可以提前帮助我。

祝好,帕特里克 解决方案

通过添加以下maven依赖项:

 <依赖项> 
< groupId> org.apache.tomcat.embed< / groupId>
< artifactId> tomcat-embed-websocket< / artifactId>
< version> 7.0.52< / version>
< /依赖关系>

正如Craig Otis指出的那样,如果您计划部署到Tomcat,您应该使用< scope> test< / scope> ,以确保您不会在构建工件中包含依赖项。


I need Websockets for real-time updates in my application. So i found this example and did it step by step here. I went through the tutorial and finally i got this exception when starting the application:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name

'org.springframework.web.socket.server.support.DefaultHandshakeHandler#0': Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.web.socket.server.support.DefaultHandshakeHandler]: Constructor threw exception; nested exception is java.lang.IllegalStateException: No suitable default RequestUpgradeStrategy found

I have searched a lot, but i didn't find a solution.

I hope anyone can help me, thanks in advance.

best regards, patrick

解决方案

I managed to resolve this issue by adding the following maven dependency:

<dependency>
   <groupId>org.apache.tomcat.embed</groupId>
   <artifactId>tomcat-embed-websocket</artifactId>
   <version>7.0.52</version>
</dependency>

As pointed by Craig Otis, if you're planning on deploying to Tomcat anyway, you should use <scope>test</scope> to ensure you don't include the dependency in your build artifact.

这篇关于Spring 4 MVC和Websockets - 没有合适的默认RequestUpgradeStrategy的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆