当前位置:   article > 正文

RabbitMQ在SpringBoot项目中集成消息总线的时候启动报错java.io.IOException_rabbit java.io.ioexception: null

rabbit java.io.ioexception: null

 最近在springboot整合rabbitmq,进行消息总线配置的时候,启动项目报错:org.springframework.amqp.AmqpIOException: java.io.IOException,详细报错如下

  1. org.springframework.amqp.AmqpIOException: java.io.IOException
  2. at org.springframework.amqp.rabbit.support.RabbitExceptionTranslator.convertRabbitAccessException(RabbitExceptionTranslator.java:71) ~[spring-rabbit-2.2.2.RELEASE.jar:2.2.2.RELEASE]
  3. at org.springframework.amqp.rabbit.connection.AbstractConnectionFactory.createBareConnection(AbstractConnectionFactory.java:510) ~[spring-rabbit-2.2.2.RELEASE.jar:2.2.2.RELEASE]
  4. at org.springframework.amqp.rabbit.connection.CachingConnectionFactory.createConnection(CachingConnectionFactory.java:751) ~[spring-rabbit-2.2.2.RELEASE.jar:2.2.2.RELEASE]
  5. at org.springframework.amqp.rabbit.connection.ConnectionFactoryUtils.createConnection(ConnectionFactoryUtils.java:215) ~[spring-rabbit-2.2.2.RELEASE.jar:2.2.2.RELEASE]
  6. at org.springframework.amqp.rabbit.core.RabbitTemplate.doExecute(RabbitTemplate.java:2085) ~[spring-rabbit-2.2.2.RELEASE.jar:2.2.2.RELEASE]
  7. at org.springframework.amqp.rabbit.core.RabbitTemplate.execute(RabbitTemplate.java:2058) ~[spring-rabbit-2.2.2.RELEASE.jar:2.2.2.RELEASE]
  8. at org.springframework.amqp.rabbit.core.RabbitTemplate.execute(RabbitTemplate.java:2038) ~[spring-rabbit-2.2.2.RELEASE.jar:2.2.2.RELEASE]
  9. at org.springframework.boot.actuate.amqp.RabbitHealthIndicator.getVersion(RabbitHealthIndicator.java:49) ~[spring-boot-actuator-2.2.2.RELEASE.jar:2.2.2.RELEASE]
  10. at org.springframework.boot.actuate.amqp.RabbitHealthIndicator.doHealthCheck(RabbitHealthIndicator.java:44) ~[spring-boot-actuator-2.2.2.RELEASE.jar:2.2.2.RELEASE]
  11. at org.springframework.boot.actuate.health.AbstractHealthIndicator.health(AbstractHealthIndicator.java:82) ~[spring-boot-actuator-2.2.2.RELEASE.jar:2.2.2.RELEASE]
  12. at org.springframework.boot.actuate.health.HealthIndicator.getHealth(HealthIndicator.java:37) [spring-boot-actuator-2.2.2.RELEASE.jar:2.2.2.RELEASE]
  13. at org.springframework.boot.actuate.health.HealthEndpoint.getHealth(HealthEndpoint.java:81) [spring-boot-actuator-2.2.2.RELEASE.jar:2.2.2.RELEASE]
  14. at org.springframework.boot.actuate.health.HealthEndpoint.getHealth(HealthEndpoint.java:38) [spring-boot-actuator-2.2.2.RELEASE.jar:2.2.2.RELEASE]
  15. at org.springframework.boot.actuate.health.HealthEndpointSupport.getContribution(HealthEndpointSupport.java:108) [spring-boot-actuator-2.2.2.RELEASE.jar:2.2.2.RELEASE]
  16. at org.springframework.boot.actuate.health.HealthEndpointSupport.getAggregateHealth(HealthEndpointSupport.java:119) [spring-boot-actuator-2.2.2.RELEASE.jar:2.2.2.RELEASE]
  17. at org.springframework.boot.actuate.health.HealthEndpointSupport.getContribution(HealthEndpointSupport.java:105) [spring-boot-actuator-2.2.2.RELEASE.jar:2.2.2.RELEASE]
  18. at org.springframework.boot.actuate.health.HealthEndpointSupport.getHealth(HealthEndpointSupport.java:83) [spring-boot-actuator-2.2.2.RELEASE.jar:2.2.2.RELEASE]
  19. at org.springframework.boot.actuate.health.HealthEndpointSupport.getHealth(HealthEndpointSupport.java:70) [spring-boot-actuator-2.2.2.RELEASE.jar:2.2.2.RELEASE]
  20. at org.springframework.boot.actuate.health.HealthEndpoint.health(HealthEndpoint.java:75) [spring-boot-actuator-2.2.2.RELEASE.jar:2.2.2.RELEASE]
  21. at org.springframework.boot.actuate.health.HealthEndpoint.health(HealthEndpoint.java:65) [spring-boot-actuator-2.2.2.RELEASE.jar:2.2.2.RELEASE]
  22. at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_181]
  23. at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_181]
  24. at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_181]
  25. at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_181]
  26. at org.springframework.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:282) [spring-core-5.2.2.RELEASE.jar:5.2.2.RELEASE]
  27. at org.springframework.boot.actuate.endpoint.invoke.reflect.ReflectiveOperationInvoker.invoke(ReflectiveOperationInvoker.java:77) [spring-boot-actuator-2.2.2.RELEASE.jar:2.2.2.RELEASE]
  28. at org.springframework.boot.actuate.endpoint.annotation.AbstractDiscoveredOperation.invoke(AbstractDiscoveredOperation.java:60) [spring-boot-actuator-2.2.2.RELEASE.jar:2.2.2.RELEASE]
  29. at org.springframework.boot.actuate.endpoint.jmx.EndpointMBean.invoke(EndpointMBean.java:121) [spring-boot-actuator-2.2.2.RELEASE.jar:2.2.2.RELEASE]
  30. at org.springframework.boot.actuate.endpoint.jmx.EndpointMBean.invoke(EndpointMBean.java:96) [spring-boot-actuator-2.2.2.RELEASE.jar:2.2.2.RELEASE]
  31. at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819) [na:1.8.0_181]
  32. at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801) [na:1.8.0_181]
  33. at javax.management.remote.rmi.RMIConnectionImpl.doOperation(RMIConnectionImpl.java:1468) [na:1.8.0_181]
  34. at javax.management.remote.rmi.RMIConnectionImpl.access$300(RMIConnectionImpl.java:76) [na:1.8.0_181]
  35. at javax.management.remote.rmi.RMIConnectionImpl$PrivilegedOperation.run(RMIConnectionImpl.java:1309) [na:1.8.0_181]
  36. at javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(RMIConnectionImpl.java:1401) [na:1.8.0_181]
  37. at javax.management.remote.rmi.RMIConnectionImpl.invoke(RMIConnectionImpl.java:829) [na:1.8.0_181]
  38. at sun.reflect.GeneratedMethodAccessor129.invoke(Unknown Source) ~[na:na]
  39. at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_181]
  40. at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_181]
  41. at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:357) [na:1.8.0_181]
  42. at sun.rmi.transport.Transport$1.run(Transport.java:200) [na:1.8.0_181]
  43. at sun.rmi.transport.Transport$1.run(Transport.java:197) [na:1.8.0_181]
  44. at java.security.AccessController.doPrivileged(Native Method) [na:1.8.0_181]
  45. at sun.rmi.transport.Transport.serviceCall(Transport.java:196) [na:1.8.0_181]
  46. at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:573) [na:1.8.0_181]
  47. at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:834) [na:1.8.0_181]
  48. at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:688) [na:1.8.0_181]
  49. at java.security.AccessController.doPrivileged(Native Method) [na:1.8.0_181]
  50. at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:687) [na:1.8.0_181]
  51. at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) ~[na:1.8.0_181]
  52. at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) ~[na:1.8.0_181]
  53. at java.lang.Thread.run(Thread.java:748) ~[na:1.8.0_181]
  54. Caused by: java.io.IOException: null
  55. at com.rabbitmq.client.impl.AMQChannel.wrap(AMQChannel.java:129) ~[amqp-client-5.7.3.jar:5.7.3]
  56. at com.rabbitmq.client.impl.AMQChannel.wrap(AMQChannel.java:125) ~[amqp-client-5.7.3.jar:5.7.3]
  57. at com.rabbitmq.client.impl.AMQChannel.exnWrappingRpc(AMQChannel.java:147) ~[amqp-client-5.7.3.jar:5.7.3]
  58. at com.rabbitmq.client.impl.AMQConnection.start(AMQConnection.java:403) ~[amqp-client-5.7.3.jar:5.7.3]
  59. at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:1115) ~[amqp-client-5.7.3.jar:5.7.3]
  60. at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:1063) ~[amqp-client-5.7.3.jar:5.7.3]
  61. at org.springframework.amqp.rabbit.connection.AbstractConnectionFactory.connect(AbstractConnectionFactory.java:526) ~[spring-rabbit-2.2.2.RELEASE.jar:2.2.2.RELEASE]
  62. at org.springframework.amqp.rabbit.connection.AbstractConnectionFactory.createBareConnection(AbstractConnectionFactory.java:473) ~[spring-rabbit-2.2.2.RELEASE.jar:2.2.2.RELEASE]
  63. ... 50 common frames omitted
  64. Caused by: com.rabbitmq.client.ShutdownSignalException: connection error; protocol method: #method<connection.close>(reply-code=530, reply-text=NOT_ALLOWED - vhost / not found, class-id=10, method-id=40)
  65. at com.rabbitmq.utility.ValueOrException.getValue(ValueOrException.java:66) ~[amqp-client-5.7.3.jar:5.7.3]
  66. at com.rabbitmq.utility.BlockingValueOrException.uninterruptibleGetValue(BlockingValueOrException.java:36) ~[amqp-client-5.7.3.jar:5.7.3]
  67. at com.rabbitmq.client.impl.AMQChannel$BlockingRpcContinuation.getReply(AMQChannel.java:502) ~[amqp-client-5.7.3.jar:5.7.3]
  68. at com.rabbitmq.client.impl.AMQChannel.privateRpc(AMQChannel.java:293) ~[amqp-client-5.7.3.jar:5.7.3]
  69. at com.rabbitmq.client.impl.AMQChannel.exnWrappingRpc(AMQChannel.java:141) ~[amqp-client-5.7.3.jar:5.7.3]
  70. ... 55 common frames omitted

后来查看yml文件中的rabbitmq相关配置:

最开始是写成这样的,然后启动报错

  1. #rabbitmq相关配置,此处一定注意rabbitmq是在spring下面的,不要顶格写配置,会报错
  2. rabbitmq:
  3. host: localhost
  4. port: 5672
  5. username: admin
  6. password: admin

最后添加了一行配置virtual-host,启动就正常ok了~

  1. #rabbitmq相关配置,此处一定注意rabbitmq是在spring下面的,不要顶格写配置,会报错
  2. rabbitmq:
  3. host: localhost
  4. port: 5672
  5. username: admin
  6. password: admin
  7. virtual-host: my_vhost

此处的virtual-host的值可以通过web管理页面查看:

本文内容由网友自发贡献,转载请注明出处:https://www.wpsshop.cn/w/你好赵伟/article/detail/1018413
推荐阅读
相关标签
  

闽ICP备14008679号