【问题标题】:Spring web socket - Cannot locate BeanDefinitionParser for element [message-broker]Spring web socket - 找不到元素的BeanDefinitionParser [消息代理]
【发布时间】:2016-07-04 13:07:11
【问题描述】:

我正在尝试在 Spring Web 应用程序中添加 spring-websocket 依赖项。

我已经在 pom.xml 中添加了这个依赖:

<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-websocket</artifactId>
    <version>4.2.4</version>
</dependency>

我已经为@EnableWebSocketMessageBroker 创建了一个等效的XML 配置,如下所示:

http://docs.spring.io/spring/docs/current/spring-framework-reference/html/websocket.html#websocket-stomp-enable

所以,我有这个 spring-socket-context.xml:

<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:websocket="http://www.springframework.org/schema/websocket"
    xsi:schemaLocation="
        http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/websocket
        http://www.springframework.org/schema/websocket/spring-websocket.xsd">

    <websocket:message-broker application-destination-prefix="/app">
        <websocket:stomp-endpoint path="/myPath">
            <websocket:sockjs/>
        </websocket:stomp-endpoint>
        <websocket:simple-broker prefix="/topic, /queue"/>
    </websocket:message-broker>

</beans>

当我启动网络应用程序时,我立即出现此错误:

[ERROR] 2016-07-04 14:52:11,381 [] []  org.springframework.web.context.ContextLoader initWebApplicationContext - Context initialization failed
org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Cannot locate BeanDefinitionParser for element [message-broker]

如何解决这个错误?

谢谢。

【问题讨论】:

    标签: spring spring-mvc spring-websocket


    【解决方案1】:

    我遇到了和你一样的错误。

    事实证明,您需要在类路径中添加 spring-messaging jar 才能在 xml 中使用 websocket:message-broker

    错误信息根本没有帮助

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-08-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-06-21
      相关资源
      最近更新 更多