谷粒商城rabbitMQ模块测试类创建交换机报错
报错详情:
org.springframework.amqp.AmqpIOException: java.io.IOException
at org.springframework.amqp.rabbit.support.RabbitExceptionTranslator.convertRabbitAccessException(RabbitExceptionTranslator.java:71) ~[spring-rabbit-2.1.8.RELEASE.jar:2.1.8.RELEASE]
at org.springframework.amqp.rabbit.connection.SimpleConnection.createChannel(SimpleConnection.java:68) ~[spring-rabbit-2.1.8.RELEASE.jar:2.1.8.RELEASE]
at org.springframework.amqp.rabbit.connection.CachingConnectionFactory$ChannelCachingConnectionProxy.createBareChannel(CachingConnectionFactory.java:1375) ~[spring-rabbit-2.1.8.RELEASE.jar:2.1.8.RELEASE]
at org.springframework.amqp.rabbit.connection.CachingConnectionFactory$ChannelCachingConnectionProxy.access$200(CachingConnectionFactory.java:1361) ~[spring-rabbit-2.1.8.RELEASE.jar:2.1.8.RELEASE]
at org.springframework.amqp.rabbit.connection.CachingConnectionFactory.doCreateBareChannel(CachingConnectionFactory.java:674) ~[spring-rabbit-2.1.8.RELEASE.jar:2.1.8.RELEASE]
at org.springframework.amqp.rabbit.connection.CachingConnectionFactory.createBareChannel(CachingConnectionFactory.java:657) ~[spring-rabbit-2.1.8.RELEASE.jar:2.1.8.RELEASE]
at org.springframework.amqp.rabbit.connection.CachingConnectionFactory.getCachedChannelProxy(CachingConnectionFactory.java:627) ~[spring-rabbit-2.1.8.RELEASE.jar:2.1.8.RELEASE]
at org.springframework.amqp.rabbit.connection.CachingConnectionFactory.getChannel(CachingConnectionFactory.java:518) ~[spring-rabbit-2.1.8.RELEASE.jar:2.1.8.RELEASE]
at org.springframework.amqp.rabbit.connection.CachingConnectionFactory.access$1700(CachingConnectionFactory.java:102) ~[spring-rabbit-2.1.8.RELEASE.jar:2.1.8.RELEASE]
at org.springframework.amqp.rabbit.connection.CachingConnectionFactory$ChannelCachingConnectionProxy.createChannel(CachingConnectionFactory.java:1380) ~[spring-rabbit-2.1.8.RELEASE.jar:2.1.8.RELEASE]
at org.springframework.amqp.rabbit.core.RabbitTemplate.doExecute(RabbitTemplate.java:2082) ~[spring-rabbit-2.1.8.RELEASE.jar:2.1.8.RELEASE]
at org.springframework.amqp.rabbit.core.RabbitTemplate.execute(RabbitTemplate.java:2050) ~[spring-rabbit-2.1.8.RELEASE.jar:2.1.8.RELEASE]
at org.springframework.amqp.rabbit.core.RabbitTemplate.execute(RabbitTemplate.java:2030) ~[spring-rabbit-2.1.8.RELEASE.jar:2.1.8.RELEASE]
at org.springframework.amqp.rabbit.core.RabbitAdmin.initialize(RabbitAdmin.java:591) ~[spring-rabbit-2.1.8.RELEASE.jar:2.1.8.RELEASE]
at org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer.attemptDeclarations(AbstractMessageListenerContainer.java:1781) ~[spring-rabbit-2.1.8.RELEASE.jar:2.1.8.RELEASE]
at org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer.redeclareElementsIfNecessary(AbstractMessageListenerContainer.java:1758) ~[spring-rabbit-2.1.8.RELEASE.jar:2.1.8.RELEASE]
at org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer$AsyncMessageProcessingConsumer.initialize(SimpleMessageListenerContainer.java:1195) [spring-rabbit-2.1.8.RELEASE.jar:2.1.8.RELEASE]
at org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer$AsyncMessageProcessingConsumer.run(SimpleMessageListenerContainer.java:1041) [spring-rabbit-2.1.8.RELEASE.jar:2.1.8.RELEASE]
at java.lang.Thread.run(Thread.java:748) [na:1.8.0_241]
Caused by: java.io.IOException: null
at com.rabbitmq.client.impl.AMQChannel.wrap(AMQChannel.java:126) ~[amqp-client-5.4.3.jar:5.4.3]
at com.rabbitmq.client.impl.AMQChannel.wrap(AMQChannel.java:122) ~[amqp-client-5.4.3.jar:5.4.3]
at com.rabbitmq.client.impl.AMQChannel.exnWrappingRpc(AMQChannel.java:144) ~[amqp-client-5.4.3.jar:5.4.3]
at com.rabbitmq.client.impl.ChannelN.open(ChannelN.java:133) ~[amqp-client-5.4.3.jar:5.4.3]
at com.rabbitmq.client.impl.ChannelManager.createChannel(ChannelManager.java:176) ~[amqp-client-5.4.3.jar:5.4.3]
at com.rabbitmq.client.impl.AMQConnection.createChannel(AMQConnection.java:553) ~[amqp-client-5.4.3.jar:5.4.3]
at org.springframework.amqp.rabbit.connection.SimpleConnection.createChannel(SimpleConnection.java:57) ~[spring-rabbit-2.1.8.RELEASE.jar:2.1.8.RELEASE]
... 17 common frames omitted
Caused by: com.rabbitmq.client.ShutdownSignalException: connection error
at com.rabbitmq.utility.ValueOrException.getValue(ValueOrException.java:66) ~[amqp-client-5.4.3.jar:5.4.3]
at com.rabbitmq.utility.BlockingValueOrException.uninterruptibleGetValue(BlockingValueOrException.java:36) ~[amqp-client-5.4.3.jar:5.4.3]
at com.rabbitmq.client.impl.AMQChannel$BlockingRpcContinuation.getReply(AMQChannel.java:494) ~[amqp-client-5.4.3.jar:5.4.3]
at com.rabbitmq.client.impl.AMQChannel.privateRpc(AMQChannel.java:288) ~[amqp-client-5.4.3.jar:5.4.3]
at com.rabbitmq.client.impl.AMQChannel.exnWrappingRpc(AMQChannel.java:138) ~[amqp-client-5.4.3.jar:5.4.3]
... 21 common frames omitted
Caused by: java.net.SocketException: Connection reset
at java.net.SocketInputStream.read(SocketInputStream.java:210) ~[na:1.8.0_241]
at java.net.SocketInputStream.read(SocketInputStream.java:141) ~[na:1.8.0_241]
at java.io.BufferedInputStream.fill(BufferedInputStream.java:246) ~[na:1.8.0_241]
at java.io.BufferedInputStream.read(BufferedInputStream.java:265) ~[na:1.8.0_241]
at java.io.DataInputStream.readUnsignedByte(DataInputStream.java:288) ~[na:1.8.0_241]
at com.rabbitmq.client.impl.Frame.readFrom(Frame.java:91) ~[amqp-client-5.4.3.jar:5.4.3]
at com.rabbitmq.client.impl.SocketFrameHandler.readFrame(SocketFrameHandler.java:164) ~[amqp-client-5.4.3.jar:5.4.3]
at com.rabbitmq.client.impl.AMQConnection$MainLoop.run(AMQConnection.java:596) ~[amqp-client-5.4.3.jar:5.4.3]
... 1 common frames omitted
错误原因:
gulimall-ware 模块中有个MyRabbitmqConfig,也注入到了容器中,与@RunWith(SpringRunner.class)
后注入到容器内的
@Autowired
AmqpAdmin amqpAdmin;
产生冲突,导致报错
解决办法:
将MyRabbitmqConfig上的@Configuration注释掉
其他错误:
SpringBoot单元测试中有了@Test注解但是idea没有执行的按钮
解决办法:如果你用的版本是spring boot 2.2之前的版本你给他加上public就行