2016-07-04 29 views
1

我試圖在Spring Web應用程序中添加spring-websocket依賴項。春天的網絡套接字 - 找不到BeanDefinitionParser的元素[消息代理]

我已經添加在pom.xml這種依賴關係:

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

而且我已經創建了一個XML配置等價物@EnableWebSocketMessageBroker,如下所示:所以

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] 

如何解決此錯誤?

謝謝。

回答

0

我遇到了和你一樣的錯誤。

事實證明,你將需要彈簧消息在類路徑罐子才能使用的WebSocket:消息經紀人在XML。

錯誤信息根本沒有幫助

相關問題