java项目启动遇到的问题如下
03-12 16:24:37 WARN [restartedMain] o.s.amqp.rabbit.core.RabbitAdmin: Failed to declare binding: Binding [destination=zyccn.log, exchange=zyccn.topicExchange, routingKey=zyccn.routing_key_log, arguments={}], continuing... org.springframework.amqp.AmqpConnectException: java.net.ConnectException: Connection refused: no further information 03-12 16:24:37 INFO [restartedMain] o.s.a.r.c.AbstractConnectionFactory: Attempting to connect to: [localhost] 03-12 16:24:37 WARN [restartedMain] o.s.amqp.rabbit.core.RabbitAdmin: Failed to declare exchange: Exchange [name=zyccn.topicExchange, type=topic, durable=true, autoDelete=false, internal=false, arguments={}], continuing... org.springframework.amqp.AmqpConnectException: java.net.ConnectException: Connection refused: no further information 03-12 16:24:39 INFO [restartedMain] o.s.s.w.DefaultSecurityFilterChain: Will secure any request with [org.springframework.security.web.session.DisableEncodeUrlFilter@6cb092c7, org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter@582b3e8, org.springframework.security.web.context.SecurityContextHolderFilter@5c473e51, org.springframework.security.web.header.HeaderWriterFilter@67a52b4b, org.springframework.web.filter.CorsFilter@68886c48, org.springframework.security.web.authentication.logout.LogoutFilter@508308b, com.qm.zyccn.zyccbackend.core.security.JwtAuthenticationFilter@515c1ebf, org.springframework.security.web.savedrequest.RequestCacheAwareFilter@5432ca0, org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter@50c46651, org.springframework.security.web.authentication.AnonymousAuthenticationFilter@5267bac3, org.springframework.security.web.session.SessionManagementFilter@23f5ff68, org.springframework.security.web.access.ExceptionTranslationFilter@4f8fbdae, org.springframework.security.web.access.intercept.AuthorizationFilter@55b03750] 03-12 16:24:39 INFO [restartedMain] o.s.b.w.e.tomcat.TomcatWebServer: Tomcat started on port 8080 (http) with context path '' 03-12 16:24:39 INFO [restartedMain] o.s.a.r.c.AbstractConnectionFactory: Attempting to connect to: [localhost] 03-12 16:24:39 INFO [restartedMain] o.s.a.r.l.AbstractMessageListenerContainer: Broker not available; cannot force queue declarations during start: java.net.ConnectException: Connection refused: no further information 03-12 16:24:39 INFO [org.springframework.amqp.rabbit.RabbitListenerEndpointContainer#0-1] o.s.a.r.c.AbstractConnectionFactory: Attempting to connect to: [localhost] 03-12 16:24:39 ERROR [org.springframework.amqp.rabbit.RabbitListenerEndpointContainer#0-1] o.s.a.r.l.AbstractMessageListenerContainer: Failed to check/redeclare auto-delete queue(s). org.springframework.amqp.AmqpConnectException: java.net.ConnectException: Connection refused: no further information at org.springframework.amqp.rabbit.support.RabbitExceptionTranslator.convertRabbitAccessException(RabbitExceptionTranslator.java:61) at org.springframework.amqp.rabbit.connection.AbstractConnectionFactory.createBareConnection(AbstractConnectionFactory.java:594) at org.springframework.amqp.rabbit.connection.CachingConnectionFactory.createConnection(CachingConnectionFactory.java:711) at org.springframework.amqp.rabbit.connection.ConnectionFactoryUtils.createConnection(ConnectionFactoryUtils.java:257) at org.springframework.amqp.rabbit.core.RabbitTemplate.doExecute(RabbitTemplate.java:2225) at org.springframework.amqp.rabbit.core.RabbitTemplate.execute(RabbitTemplate.java:2198) at org.springframework.amqp.rabbit.core.RabbitTemplate.execute(RabbitTemplate.java:2178) at org.springframework.amqp.rabbit.core.RabbitAdmin.getQueueInfo(RabbitAdmin.java:465) at org.springframework.amqp.rabbit.core.RabbitAdmin.getQueueProperties(RabbitAdmin.java:449) at org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer.attemptDeclarations(AbstractMessageListenerContainer.java:1936) at org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer.redeclareElementsIfNecessary(AbstractMessageListenerContainer.java:1904) at org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer$AsyncMessageProcessingConsumer.initialize(SimpleMessageListenerContainer.java:1383) at org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer$AsyncMessageProcessingConsumer.run(SimpleMessageListenerContainer.java:1225) at java.base/java.lang.Thread.run(Thread.java:842) Caused by: java.net.ConnectException: Connection refused: no further information at java.base/sun.nio.ch.Net.pollConnect(Native Method) at java.base/sun.nio.ch.Net.pollConnectNow(Net.java:672) at java.base/sun.nio.ch.NioSocketImpl.timedFinishConnect(NioSocketImpl.java:547) at java.base/sun.nio.ch.NioSocketImpl.connect(NioSocketImpl.java:602) at java.base/java.net.SocksSocketImpl.connect(SocksSocketImpl.java:327) at java.base/java.net.Socket.connect(Socket.java:633) at com.rabbitmq.client.impl.SocketFrameHandlerFactory.create(SocketFrameHandlerFactory.java:61) at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:1249) at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:1198) at org.springframework.amqp.rabbit.connection.AbstractConnectionFactory.connectAddresses(AbstractConnectionFactory.java:632) at org.springframework.amqp.rabbit.connection.AbstractConnectionFactory.connect(AbstractConnectionFactory.java:607) at org.springframework.amqp.rabbit.connection.AbstractConnectionFactory.createBareConnection(AbstractConnectionFactory.java:557) ... 12 common frames omitted 03-12 16:24:39 INFO [org.springframework.amqp.rabbit.RabbitListenerEndpointContainer#0-1] o.s.a.r.c.AbstractConnectionFactory: Attempting to connect to: [localhost] 03-12 16:24:39 INFO [restartedMain] o.s.a.r.c.AbstractConnectionFactory: Attempting to connect to: [localhost] 03-12 16:24:39 INFO [restartedMain] o.s.a.r.l.AbstractMessageListenerContainer: Broker not available; cannot force queue declarations during start: java.net.ConnectException: Connection refused: no further information 03-12 16:24:39 INFO [org.springframework.amqp.rabbit.RabbitListenerEndpointContainer#1-1] o.s.a.r.c.AbstractConnectionFactory: Attempting to connect to: [localhost] 03-12 16:24:39 ERROR [org.springframework.amqp.rabbit.RabbitListenerEndpointContainer#1-1] o.s.a.r.l.AbstractMessageListenerContainer: Failed to check/redeclare auto-delete queue(s). org.springframework.amqp.AmqpConnectException: java.net.ConnectException: Connection refused: no further information at org.springframework.amqp.rabbit.support.RabbitExceptionTranslator.convertRabbitAccessException(RabbitExceptionTranslator.java:61) at org.springframework.amqp.rabbit.connection.AbstractConnectionFactory.createBareConnection(AbstractConnectionFactory.java:594) at org.springframework.amqp.rabbit.connection.CachingConnectionFactory.createConnection(CachingConnectionFactory.java:711) at org.springframework.amqp.rabbit.connection.ConnectionFactoryUtils.createConnection(ConnectionFactoryUtils.java:257) at org.springframework.amqp.rabbit.core.RabbitTemplate.doExecute(RabbitTemplate.java:2225) at org.springframework.amqp.rabbit.core.RabbitTemplate.execute(RabbitTemplate.java:2198) at org.springframework.amqp.rabbit.core.RabbitTemplate.execute(RabbitTemplate.java:2178) at org.springframework.amqp.rabbit.core.RabbitAdmin.getQueueInfo(RabbitAdmin.java:465) at org.springframework.amqp.rabbit.core.RabbitAdmin.getQueueProperties(RabbitAdmin.java:449) at org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer.attemptDeclarations(AbstractMessageListenerContainer.java:1936) at org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer.redeclareElementsIfNecessary(AbstractMessageListenerContainer.java:1904) at org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer$AsyncMessageProcessingConsumer.initialize(SimpleMessageListenerContainer.java:1383) at org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer$AsyncMessageProcessingConsumer.run(SimpleMessageListenerContainer.java:1225) at java.base/java.lang.Thread.run(Thread.java:842) Caused by: java.net.ConnectException: Connection refused: no further information at java.base/sun.nio.ch.Net.pollConnect(Native Method) at java.base/sun.nio.ch.Net.pollConnectNow(Net.java:672) at java.base/sun.nio.ch.NioSocketImpl.timedFinishConnect(NioSocketImpl.java:547) at java.base/sun.nio.ch.NioSocketImpl.connect(NioSocketImpl.java:602) at java.base/java.net.SocksSocketImpl.connect(SocksSocketImpl.java:327) at java.base/java.net.Socket.connect(Socket.java:633) at com.rabbitmq.client.impl.SocketFrameHandlerFactory.create(SocketFrameHandlerFactory.java:61) at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:1249) at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:1198) at org.springframework.amqp.rabbit.connection.AbstractConnectionFactory.connectAddresses(AbstractConnectionFactory.java:632) at org.springframework.amqp.rabbit.connection.AbstractConnectionFactory.connect(AbstractConnectionFactory.java:607) at org.springframework.amqp.rabbit.connection.AbstractConnectionFactory.createBareConnection(AbstractConnectionFactory.java:557) ... 12 common frames omitted 03-12 16:24:39 INFO [org.springframework.amqp.rabbit.RabbitListenerEndpointContainer#1-1] o.s.a.r.c.AbstractConnectionFactory: Attempting to connect to: [localhost] 03-12 16:24:39 INFO [restartedMain] o.s.boot.StartupInfoLogger: Started ZyccnBackendApplication in 15.561 seconds (process running for 16.238) 03-12 16:24:39 INFO [restartedMain] c.q.z.z.c.c.cache.ApplicationCache: ApplicationCache Init start 03-12 16:24:42 INFO [restartedMain] c.q.z.z.c.c.cache.ApplicationCache: ApplicationCache Init end 03-12 16:24:44 WARN [org.springframework.amqp.rabbit.RabbitListenerEndpointContainer#0-1] o.s.a.r.l.SimpleMessageListenerContainer$AsyncMessageProcessingConsumer: Consumer raised exception, processing can restart if the connection factory supports it. Exception summary: org.springframework.amqp.AmqpConnectException: java.net.ConnectException: Connection refused: no further information 03-12 16:24:44 WARN [org.springframework.amqp.rabbit.RabbitListenerEndpointContainer#1-1] o.s.a.r.l.SimpleMessageListenerContainer$AsyncMessageProcessingConsumer: Consumer raised exception, processing can restart if the connection factory supports it. Exception summary: org.springframework.amqp.AmqpConnectException: java.net.ConnectException: Connection refused: no further information 03-12 16:24:44 INFO [org.springframework.amqp.rabbit.RabbitListenerEndpointContainer#1-1] o.s.a.r.l.SimpleMessageListenerContainer$AsyncMessageProcessingConsumer: Restarting Consumer@1bd00ad6: tags=[[]], channel=null, acknowledgeMode=AUTO local queue size=0 03-12 16:24:44 INFO [org.springframework.amqp.rabbit.RabbitListenerEndpointContainer#0-1] o.s.a.r.l.SimpleMessageListenerContainer$AsyncMessageProcessingConsumer: Restarting Consumer@486b3bf8: tags=[[]], channel=null, acknowledgeMode=AUTO local queue size=0 03-12 16:24:44 INFO [org.springframework.amqp.rabbit.RabbitListenerEndpointContainer#0-2] o.s.a.r.c.AbstractConnectionFactory: Attempting to connect to: [localhost] 03-12 16:24:44 ERROR [org.springframework.amqp.rabbit.RabbitListenerEndpointContainer#0-2] o.s.a.r.l.AbstractMessageListenerContainer: Failed to check/redeclare auto-delete queue(s). 03-12 16:24:44 INFO [org.springframework.amqp.rabbit.RabbitListenerEndpointContainer#1-2] o.s.a.r.c.AbstractConnectionFactory: Attempting to connect to: [localhost] 03-12 16:24:44 ERROR [org.springframework.amqp.rabbit.RabbitListenerEndpointContainer#1-2] o.s.a.r.l.AbstractMessageListenerContainer: Failed to check/redeclare auto-delete queue(s). 03-12 16:24:44 INFO [org.springframework.amqp.rabbit.RabbitListenerEndpointContainer#0-2] o.s.a.r.c.AbstractConnectionFactory: Attempting to connect to: [localhost] 03-12 16:24:44 INFO [org.springframework.amqp.rabbit.RabbitListenerEndpointContainer#1-2] o.s.a.r.c.AbstractConnectionFactory: Attempting to connect to: [localhost]
主要是以下问题
Connection refused: no further information 连接被拒绝rabbitmq的
一般的解决办法
- 服务器未启动:检查你的服务器(如 Java 后端、数据库、Minecraft 服务器等)是否正在运行。
- 端口错误:确保客户端连接的端口与服务器监听的端口一致。
- 防火墙或安全组限制:检查你的防火墙、Windows Defender 或云服务器的安全组,确保它们允许相关端口的访问。
- IP 地址问题:如果你连接的是本地服务器,确保使用
localhost
或127.0.0.1
,而不是外部 IP。如果是远程服务器,确认 IP 是否正确。 - 服务崩溃或进程被占用:检查服务器日志,看是否有异常导致服务崩溃,或者端口是否被其他进程占用。
端口一致,配置文件未更改,所以端口,ip地址没错
查看防火墙看是否关闭了
或者防火墙是否放端口号:5672过
发现没有问题,但是连接还是被拒绝
然后查看进程是否被占用
在 Windows 上:
- 查看进程:
-
打开任务管理器(Ctrl + Shift + Esc),在“进程”选项卡中可以查看所有正在运行的进程。
-
在命令提示符中,可以使用
tasklist
命令:tasklist
-
- 关闭进程:
-
在任务管理器中,右键点击要终止的进程,然后选择“结束任务”。
-
在命令提示符中,可以使用
taskkill
命令。假设你知道进程的PID为1234
:taskkill /PID 1234
-
或者通过进程名称:
taskkill /IM <进程名称>.exe
-
- 检查端口占用:
- 使用
netstat
命令: netstat -ano | findstr :<端口号>
- 找到使用该端口的PID后,可以用上面的
taskkill
命令终止该进程。
- 使用
使用netstat -ano | findstr :5672时发现并没有这个进程,说明进程没有被占用
排除进程被占用的问题
找了半天,查看任务管理器,查找Rabbitmq-server服务是否开启,发现并没有Rabbitmq-server这个服务,wcnmlgb,最后才知道windows更新系统时给我rabbitmq-server自动卸载了(可能),c
最后重新安装otp环境,重新安装rabbitmq-server,重新启动java项目,启动成功
结论:更新系统后,运行java项目连接被拒绝,第一时间想到是否是更新时自动卸载了某些软件
尤其是rabbitmq-server服务是否有