使用activemq消息队列,然后想通过注解的方式来配置监听器,
添加了以下代码:
<!--如果要用注解的方式,就不需要在xml中自己定义消息监听容器了 -->
<bean id="jmsListenerContainerFactory" class="org.springframework.jms.config.DefaultJmsListenerContainerFactory"> <property name="connectionFactory" ref="connectionFactory"/>
<!-- 监听注解支持 -->
<jms:annotation-driven/>
========================================================================
运行以后报错:
Only one JmsListenerAnnotationBeanPostProcessor may exist within the context
以下方法尝试解决:
1、取消监听器注解支持配置
2、监听类,添加注解:
@Component
@EnableJms//开启jms配置
public class QueueTestReceiver extends MessageListenerAdapter