【发布时间】:2015-06-29 06:18:13
【问题描述】:
我想在 Spring 4 中创建多个消息代理实例。我正在使用以下配置:
<websocket:message-broker application-destination-prefix="/App1" >
<websocket:stomp-endpoint path="/path1">
<websocket:sockjs/>
</websocket:stomp-endpoint>
<websocket:simple-broker prefix="/topic"/>
</websocket:message-broker>
<websocket:message-broker application-destination-prefix="/App2">
<websocket:stomp-endpoint path="/path2">
<websocket:sockjs/>
</websocket:stomp-endpoint>
<websocket:simple-broker prefix="/topic"/>
</websocket:message-broker>
在我的控制器中,我正在自动装配 SimpMessagingTemplate。
我收到以下异常:
引起:org.springframework.beans.factory.BeanCreationException:
无法自动装配字段: org.springframework.messaging.simp.SimpMessagingTemplate
com.cdk.phoenix.app.controller.tools.tail.LogTailController.template; 嵌套
例外是 org.springframework.beans.factory.NoUniqueBeanDefinitionException: 否
限定 bean 类型 [org.springframework.messaging.simp.SimpMessagingTemplate]
是 已定义:预期的单个匹配 bean,但找到了 2:
org.springframework.messaging.simp.SimpMessagingTemplate#0,org.springframework.mes
saging.simp.SimpMessagingTemplate#1
如何为不同的消息代理创建 SimpMessagingTemplate 的唯一实例?
【问题讨论】:
标签: java spring spring-mvc spring-websocket