springAMQP接收消息报错

报错问题

01-10 23:04:33:471  WARN 14400 --- [ntContainer#0-1] o.s.a.r.listener.BlockingQueueConsumer   : Failed to declare queue: simple,queue
01-10 23:04:33:474  WARN 14400 --- [ntContainer#0-1] o.s.a.r.listener.BlockingQueueConsumer   : Queue declaration failed; retries left=3

org.springframework.amqp.rabbit.listener.BlockingQueueConsumer$DeclarationException: Failed to declare queue(s):[simple,queue]
	at org.springframework.amqp.rabbit.listener.BlockingQueueConsumer.attemptPassiveDeclarations(BlockingQueueConsumer.java:712) ~[spring-rabbit-2.2.15.RELEASE.jar:2.2.15.RELEASE]
	at org.springframework.amqp.rabbit.listener.BlockingQueueConsumer.passiveDeclarations(BlockingQueueConsumer.java:595) ~[spring-rabbit-2.2.15.RELEASE.jar:2.2.15.RELEASE]
	at org.springframework.amqp.rabbit.listener.BlockingQueueConsumer.start(BlockingQueueConsumer.java:582) ~[spring-rabbit-2.2.15.RELEASE.jar:2.2.15.RELEASE]
	at org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer$AsyncMessageProcessingConsumer.initialize(SimpleMessageListenerContainer.java:1356) ~[spring-rabbit-2.2.15.RELEASE.jar:2.2.15.RELEASE]
	at org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer$AsyncMessageProcessingConsumer.run(SimpleMessageListenerContainer.java:1201) ~[spring-rabbit-2.2.15.RELEASE.jar:2.2.15.RELEASE]
	at java.base/java.lang.Thread.run(Thread.java:833) ~[na:na]
Caused by: java.io.IOException: null

大家请看下面代码找出不同

代码一


@Component
public class SpringRabbitListener {
    @RabbitListener(queues = "simple,queue")
    public void listenSimpleQueue(String msg){
        System.out.println("消费者接收到simple.queue的消息:{"+msg+"}");

    }

}

代码二


@Component
public class SpringRabbitListener {
    @RabbitListener(queues = "simple.queue")
    public void listenSimpleQueue(String msg){
        System.out.println("消费者接收到simple.queue的消息:{"+msg+"}");

    }

}

我找到最后人也呆了,人直接蒙了。

后来看出来了

大家知悉看这一句


    @RabbitListener(queues = "simple.queue")

我把 "  . " 写为 ”  , “了

代码仔细,改错两行泪 

你可能感兴趣的:(开发语言,rabbitmq,spring)