赞
踩
最近在springboot整合rabbitmq,进行消息总线配置的时候,启动项目报错:org.springframework.amqp.AmqpIOException: java.io.IOException,详细报错如下
- org.springframework.amqp.AmqpIOException: java.io.IOException
- at org.springframework.amqp.rabbit.support.RabbitExceptionTranslator.convertRabbitAccessException(RabbitExceptionTranslator.java:71) ~[spring-rabbit-2.2.2.RELEASE.jar:2.2.2.RELEASE]
- at org.springframework.amqp.rabbit.connection.AbstractConnectionFactory.createBareConnection(AbstractConnectionFactory.java:510) ~[spring-rabbit-2.2.2.RELEASE.jar:2.2.2.RELEASE]
- at org.springframework.amqp.rabbit.connection.CachingConnectionFactory.createConnection(CachingConnectionFactory.java:751) ~[spring-rabbit-2.2.2.RELEASE.jar:2.2.2.RELEASE]
- at org.springframework.amqp.rabbit.connection.ConnectionFactoryUtils.createConnection(ConnectionFactoryUtils.java:215) ~[spring-rabbit-2.2.2.RELEASE.jar:2.2.2.RELEASE]
- at org.springframework.amqp.rabbit.core.RabbitTemplate.doExecute(RabbitTemplate.java:2085) ~[spring-rabbit-2.2.2.RELEASE.jar:2.2.2.RELEASE]
- at org.springframework.amqp.rabbit.core.RabbitTemplate.execute(RabbitTemplate.java:2058) ~[spring-rabbit-2.2.2.RELEASE.jar:2.2.2.RELEASE]
- at org.springframework.amqp.rabbit.core.RabbitTemplate.execute(RabbitTemplate.java:2038) ~[spring-rabbit-2.2.2.RELEASE.jar:2.2.2.RELEASE]
- at org.springframework.boot.actuate.amqp.RabbitHealthIndicator.getVersion(RabbitHealthIndicator.java:49) ~[spring-boot-actuator-2.2.2.RELEASE.jar:2.2.2.RELEASE]
- at org.springframework.boot.actuate.amqp.RabbitHealthIndicator.doHealthCheck(RabbitHealthIndicator.java:44) ~[spring-boot-actuator-2.2.2.RELEASE.jar:2.2.2.RELEASE]
- at org.springframework.boot.actuate.health.AbstractHealthIndicator.health(AbstractHealthIndicator.java:82) ~[spring-boot-actuator-2.2.2.RELEASE.jar:2.2.2.RELEASE]
- at org.springframework.boot.actuate.health.HealthIndicator.getHealth(HealthIndicator.java:37) [spring-boot-actuator-2.2.2.RELEASE.jar:2.2.2.RELEASE]
- at org.springframework.boot.actuate.health.HealthEndpoint.getHealth(HealthEndpoint.java:81) [spring-boot-actuator-2.2.2.RELEASE.jar:2.2.2.RELEASE]
- at org.springframework.boot.actuate.health.HealthEndpoint.getHealth(HealthEndpoint.java:38) [spring-boot-actuator-2.2.2.RELEASE.jar:2.2.2.RELEASE]
- at org.springframework.boot.actuate.health.HealthEndpointSupport.getContribution(HealthEndpointSupport.java:108) [spring-boot-actuator-2.2.2.RELEASE.jar:2.2.2.RELEASE]
- at org.springframework.boot.actuate.health.HealthEndpointSupport.getAggregateHealth(HealthEndpointSupport.java:119) [spring-boot-actuator-2.2.2.RELEASE.jar:2.2.2.RELEASE]
- at org.springframework.boot.actuate.health.HealthEndpointSupport.getContribution(HealthEndpointSupport.java:105) [spring-boot-actuator-2.2.2.RELEASE.jar:2.2.2.RELEASE]
- at org.springframework.boot.actuate.health.HealthEndpointSupport.getHealth(HealthEndpointSupport.java:83) [spring-boot-actuator-2.2.2.RELEASE.jar:2.2.2.RELEASE]
- at org.springframework.boot.actuate.health.HealthEndpointSupport.getHealth(HealthEndpointSupport.java:70) [spring-boot-actuator-2.2.2.RELEASE.jar:2.2.2.RELEASE]
- at org.springframework.boot.actuate.health.HealthEndpoint.health(HealthEndpoint.java:75) [spring-boot-actuator-2.2.2.RELEASE.jar:2.2.2.RELEASE]
- at org.springframework.boot.actuate.health.HealthEndpoint.health(HealthEndpoint.java:65) [spring-boot-actuator-2.2.2.RELEASE.jar:2.2.2.RELEASE]
- at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_181]
- at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_181]
- at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_181]
- at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_181]
- at org.springframework.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:282) [spring-core-5.2.2.RELEASE.jar:5.2.2.RELEASE]
- 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]
- at org.springframework.boot.actuate.endpoint.annotation.AbstractDiscoveredOperation.invoke(AbstractDiscoveredOperation.java:60) [spring-boot-actuator-2.2.2.RELEASE.jar:2.2.2.RELEASE]
- at org.springframework.boot.actuate.endpoint.jmx.EndpointMBean.invoke(EndpointMBean.java:121) [spring-boot-actuator-2.2.2.RELEASE.jar:2.2.2.RELEASE]
- at org.springframework.boot.actuate.endpoint.jmx.EndpointMBean.invoke(EndpointMBean.java:96) [spring-boot-actuator-2.2.2.RELEASE.jar:2.2.2.RELEASE]
- at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819) [na:1.8.0_181]
- at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801) [na:1.8.0_181]
- at javax.management.remote.rmi.RMIConnectionImpl.doOperation(RMIConnectionImpl.java:1468) [na:1.8.0_181]
- at javax.management.remote.rmi.RMIConnectionImpl.access$300(RMIConnectionImpl.java:76) [na:1.8.0_181]
- at javax.management.remote.rmi.RMIConnectionImpl$PrivilegedOperation.run(RMIConnectionImpl.java:1309) [na:1.8.0_181]
- at javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(RMIConnectionImpl.java:1401) [na:1.8.0_181]
- at javax.management.remote.rmi.RMIConnectionImpl.invoke(RMIConnectionImpl.java:829) [na:1.8.0_181]
- at sun.reflect.GeneratedMethodAccessor129.invoke(Unknown Source) ~[na:na]
- at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_181]
- at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_181]
- at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:357) [na:1.8.0_181]
- at sun.rmi.transport.Transport$1.run(Transport.java:200) [na:1.8.0_181]
- at sun.rmi.transport.Transport$1.run(Transport.java:197) [na:1.8.0_181]
- at java.security.AccessController.doPrivileged(Native Method) [na:1.8.0_181]
- at sun.rmi.transport.Transport.serviceCall(Transport.java:196) [na:1.8.0_181]
- at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:573) [na:1.8.0_181]
- at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:834) [na:1.8.0_181]
- at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:688) [na:1.8.0_181]
- at java.security.AccessController.doPrivileged(Native Method) [na:1.8.0_181]
- at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:687) [na:1.8.0_181]
- at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) ~[na:1.8.0_181]
- at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) ~[na:1.8.0_181]
- at java.lang.Thread.run(Thread.java:748) ~[na:1.8.0_181]
- Caused by: java.io.IOException: null
- at com.rabbitmq.client.impl.AMQChannel.wrap(AMQChannel.java:129) ~[amqp-client-5.7.3.jar:5.7.3]
- at com.rabbitmq.client.impl.AMQChannel.wrap(AMQChannel.java:125) ~[amqp-client-5.7.3.jar:5.7.3]
- at com.rabbitmq.client.impl.AMQChannel.exnWrappingRpc(AMQChannel.java:147) ~[amqp-client-5.7.3.jar:5.7.3]
- at com.rabbitmq.client.impl.AMQConnection.start(AMQConnection.java:403) ~[amqp-client-5.7.3.jar:5.7.3]
- at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:1115) ~[amqp-client-5.7.3.jar:5.7.3]
- at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:1063) ~[amqp-client-5.7.3.jar:5.7.3]
- at org.springframework.amqp.rabbit.connection.AbstractConnectionFactory.connect(AbstractConnectionFactory.java:526) ~[spring-rabbit-2.2.2.RELEASE.jar:2.2.2.RELEASE]
- at org.springframework.amqp.rabbit.connection.AbstractConnectionFactory.createBareConnection(AbstractConnectionFactory.java:473) ~[spring-rabbit-2.2.2.RELEASE.jar:2.2.2.RELEASE]
- ... 50 common frames omitted
- 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)
- at com.rabbitmq.utility.ValueOrException.getValue(ValueOrException.java:66) ~[amqp-client-5.7.3.jar:5.7.3]
- at com.rabbitmq.utility.BlockingValueOrException.uninterruptibleGetValue(BlockingValueOrException.java:36) ~[amqp-client-5.7.3.jar:5.7.3]
- at com.rabbitmq.client.impl.AMQChannel$BlockingRpcContinuation.getReply(AMQChannel.java:502) ~[amqp-client-5.7.3.jar:5.7.3]
- at com.rabbitmq.client.impl.AMQChannel.privateRpc(AMQChannel.java:293) ~[amqp-client-5.7.3.jar:5.7.3]
- at com.rabbitmq.client.impl.AMQChannel.exnWrappingRpc(AMQChannel.java:141) ~[amqp-client-5.7.3.jar:5.7.3]
- ... 55 common frames omitted
后来查看yml文件中的rabbitmq相关配置:
最开始是写成这样的,然后启动报错
- #rabbitmq相关配置,此处一定注意rabbitmq是在spring下面的,不要顶格写配置,会报错
- rabbitmq:
- host: localhost
- port: 5672
- username: admin
- password: admin
最后添加了一行配置virtual-host,启动就正常ok了~
- #rabbitmq相关配置,此处一定注意rabbitmq是在spring下面的,不要顶格写配置,会报错
- rabbitmq:
- host: localhost
- port: 5672
- username: admin
- password: admin
- virtual-host: my_vhost
此处的virtual-host的值可以通过web管理页面查看:
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。