Spring AMQP,RabbitMQ

一、Spring AMQP的DMP(异步地消费消息)

<!-- 定义消息驱动的 AMQP POJO-->
    <listener-container connection-factory="connectionFactory">
        <listener ref="spitterAlertHandler" 
                  method="handleSpitterAlert" 
                  queue-names="spitterAlertQueue"/>
    </listener-container>

在加载时,出现下面的问题:

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.amqp.rabbit.config.ListenerContainerFactoryBean#0': Invocation of init method failed; nested exception is java.lang.NullPointerException
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1745)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:576)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:498)

该原因是由于Spring的命名空间版本不正确:

将:spring-rabbit-1.7.xsd改为 spring-rabbit.xsd,将spring-beans-4.2.xsd 改为spring-beans.xsd

Spring的命名空间

猜你喜欢

转载自blog.csdn.net/hefrankeleyn/article/details/89605293