您好,登錄后才能下訂單哦!
本篇文章給大家分享的是有關在SpringMVC項目連接RabbitMQ時出現錯誤如何解決,小編覺得挺實用的,因此分享給大家學習,希望大家閱讀完這篇文章后可以有所收獲,話不多說,跟著小編一起來看看吧。
在第一次啟動項目的時候,由于使用了RabbitMQ的默認guest賬號,怎么也登不進去,后來還是在Admin重新創建了一個其他的賬號,然后開啟所有的權限,最后在配置文件中修改了賬號,這樣才成功連接rabbitmq。
但是到今天重新啟動項目的時候,想試試guest賬號還行不行,嘗試了一次,居然可以重新啟動了,吃驚!
在此記錄,以防今后忘記。
補充:解決rabbitmq無法連接導致的錯誤
最近學寫項目的時候用到rabbitmq始終無法連接,踩了挺多坑的,希望分享出來,讓大家少踩一些. 錯誤提示是這樣的:
org.springframework.amqp.AmqpIOException: java.io.IOException at org.springframework.amqp.rabbit.support.RabbitExceptionTranslator.convertRabbitAccessException(RabbitExceptionTranslator.java:71) ~[spring-rabbit-2.0.3.RELEASE.jar:2.0.3.RELEASE] at org.springframework.amqp.rabbit.connection.AbstractConnectionFactory.createBareConnection(AbstractConnectionFactory.java:476) ~[spring-rabbit-2.0.3.RELEASE.jar:2.0.3.RELEASE] at org.springframework.amqp.rabbit.connection.CachingConnectionFactory.createConnection(CachingConnectionFactory.java:614) ~[spring-rabbit-2.0.3.RELEASE.jar:2.0.3.RELEASE] at org.springframework.amqp.rabbit.connection.ConnectionFactoryUtils.createConnection(ConnectionFactoryUtils.java:240) ~[spring-rabbit-2.0.3.RELEASE.jar:2.0.3.RELEASE] at org.springframework.amqp.rabbit.core.RabbitTemplate.doExecute(RabbitTemplate.java:1797) ~[spring-rabbit-2.0.3.RELEASE.jar:2.0.3.RELEASE] at org.springframework.amqp.rabbit.core.RabbitTemplate.execute(RabbitTemplate.java:1771) ~[spring-rabbit-2.0.3.RELEASE.jar:2.0.3.RELEASE] at org.springframework.amqp.rabbit.core.RabbitTemplate.execute(RabbitTemplate.java:1752) ~[spring-rabbit-2.0.3.RELEASE.jar:2.0.3.RELEASE] at org.springframework.boot.actuate.amqp.RabbitHealthIndicator.getVersion(RabbitHealthIndicator.java:48) ~[spring-boot-actuator-2.0.2.RELEASE.jar:2.0.2.RELEASE] at org.springframework.boot.actuate.amqp.RabbitHealthIndicator.doHealthCheck(RabbitHealthIndicator.java:44) ~[spring-boot-actuator-2.0.2.RELEASE.jar:2.0.2.RELEASE] at org.springframework.boot.actuate.health.AbstractHealthIndicator.health(AbstractHealthIndicator.java:84) ~[spring-boot-actuator-2.0.2.RELEASE.jar:2.0.2.RELEASE] at org.springframework.boot.actuate.health.CompositeHealthIndicator.health(CompositeHealthIndicator.java:68) [spring-boot-actuator-2.0.2.RELEASE.jar:2.0.2.RELEASE] at org.springframework.boot.actuate.health.HealthEndpoint.health(HealthEndpoint.java:47) [spring-boot-actuator-2.0.2.RELEASE.jar:2.0.2.RELEASE] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_202] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_202] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_202] at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_202] at org.springframework.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:223) [spring-core-5.0.6.RELEASE.jar:5.0.6.RELEASE] at org.springframework.boot.actuate.endpoint.invoke.reflect.ReflectiveOperationInvoker.invoke(ReflectiveOperationInvoker.java:76) [spring-boot-actuator-2.0.2.RELEASE.jar:2.0.2.RELEASE] at org.springframework.boot.actuate.endpoint.annotation.AbstractDiscoveredOperation.invoke(AbstractDiscoveredOperation.java:61) [spring-boot-actuator-2.0.2.RELEASE.jar:2.0.2.RELEASE] at org.springframework.boot.actuate.endpoint.jmx.EndpointMBean.invoke(EndpointMBean.java:104) [spring-boot-actuator-2.0.2.RELEASE.jar:2.0.2.RELEASE] at org.springframework.boot.actuate.endpoint.jmx.EndpointMBean.invoke(EndpointMBean.java:93) [spring-boot-actuator-2.0.2.RELEASE.jar:2.0.2.RELEASE] at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819) [na:1.8.0_202] at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801) [na:1.8.0_202] at javax.management.remote.rmi.RMIConnectionImpl.doOperation(RMIConnectionImpl.java:1468) [na:1.8.0_202] at javax.management.remote.rmi.RMIConnectionImpl.access300 ( R M I C o n n e c t i o n I m p l . j a v a : 76 ) [ n a : 1.8. 0 2 02 ] a t j a v a x . m a n a g e m e n t . r e m o t e . r m i . R M I C o n n e c t i o n I m p l 300(RMIConnectionImpl.java:76) [na:1.8.0_202] at javax.management.remote.rmi.RMIConnectionImpl300(RMIConnectionImpl.java:76)[na:1.8.0 2 02]atjavax.management.remote.rmi.RMIConnectionImplPrivilegedOperation.run(RMIConnectionImpl.java:1309) [na:1.8.0_202] at javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(RMIConnectionImpl.java:1401) [na:1.8.0_202] at javax.management.remote.rmi.RMIConnectionImpl.invoke(RMIConnectionImpl.java:829) [na:1.8.0_202] at sun.reflect.GeneratedMethodAccessor112.invoke(Unknown Source) ~[na:na] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_202] at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_202] at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:357) [na:1.8.0_202] at sun.rmi.transport.Transport$1.run(Transport.java:200) [na:1.8.0_202] at sun.rmi.transport.Transport1. r u n ( T r a n s p o r t . j a v a : 197 ) [ n a : 1.8. 0 2 02 ] a t j a v a . s e c u r i t y . A c c e s s C o n t r o l l e r . d o P r i v i l e g e d ( N a t i v e M e t h o d ) [ n a : 1.8. 0 2 02 ] a t s u n . r m i . t r a n s p o r t . T r a n s p o r t . s e r v i c e C a l l ( T r a n s p o r t . j a v a : 196 ) [ n a : 1.8. 0 2 02 ] a t s u n . r m i . t r a n s p o r t . t c p . T C P T r a n s p o r t . h a n d l e M e s s a g e s ( T C P T r a n s p o r t . j a v a : 573 ) [ n a : 1.8. 0 2 02 ] a t s u n . r m i . t r a n s p o r t . t c p . T C P T r a n s p o r t 1.run(Transport.java:197) [na:1.8.0_202] at java.security.AccessController.doPrivileged(Native Method) [na:1.8.0_202] at sun.rmi.transport.Transport.serviceCall(Transport.java:196) [na:1.8.0_202] at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:573) [na:1.8.0_202] at sun.rmi.transport.tcp.TCPTransport1.run(Transport.java:197)[na:1.8.0 2 02]atjava.security.AccessController.doPrivileged(NativeMethod)[na:1.8.0 2 02]atsun.rmi.transport.Transport.serviceCall(Transport.java:196)[na:1.8.0 2 02]atsun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:573)[na:1.8.0 2 02]atsun.rmi.transport.tcp.TCPTransportConnectionHandler.run0(TCPTransport.java:834) [na:1.8.0_202] at sun.rmi.transport.tcp.TCPTransportC o n n e c t i o n H a n d l e r . l a m b d a ConnectionHandler.lambdaConnectionHandler.lambdarun0 ( T C P T r a n s p o r t . j a v a : 688 ) [ n a : 1.8. 0 2 02 ] a t j a v a . s e c u r i t y . A c c e s s C o n t r o l l e r . d o P r i v i l e g e d ( N a t i v e M e t h o d ) [ n a : 1.8. 0 2 02 ] a t s u n . r m i . t r a n s p o r t . t c p . T C P T r a n s p o r t 0(TCPTransport.java:688) [na:1.8.0_202] at java.security.AccessController.doPrivileged(Native Method) [na:1.8.0_202] at sun.rmi.transport.tcp.TCPTransport0(TCPTransport.java:688)[na:1.8.0 2 02]atjava.security.AccessController.doPrivileged(NativeMethod)[na:1.8.0 2 02]atsun.rmi.transport.tcp.TCPTransportConnectionHandler.run(TCPTransport.java:687) [na:1.8.0_202] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) ~[na:1.8.0_202] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) ~[na:1.8.0_202] at java.lang.Thread.run(Thread.java:748) ~[na:1.8.0_202]
這是因為我們并沒有創建出用戶
首先打開rabbitmq界面add User 創建用戶
有了用戶之后是no access
點擊右邊的virtual hosts 咱們新建一個virtual host
如圖 我們設置User 然后Set Permission
這里我們直接設置為超級管理員了
(權限分為超級管理原,監控者,policymaker,普通管理員和只能產生生產者和消費者普通用戶)
當發現current permissions有了你的權限再嘗試連接就ok拉~
以上就是在SpringMVC項目連接RabbitMQ時出現錯誤如何解決,小編相信有部分知識點可能是我們日常工作會見到或用到的。希望你能通過這篇文章學到更多知識。更多詳情敬請關注億速云行業資訊頻道。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。