admin管理员组

文章数量:1608599

**

解决Redis connection refusd遇到的一个问题

**

错误描述

我做一个登陆界面时,把token令牌储存在Redis中,输入正确的账号密码时,在控制台显示如下错误。

[2020-01-31 14:20:34] [DEBUG] -- Connecting to Redis at localhost:6379: localhost:6379
io.netty.channel.AbstractChannel$AnnotatedConnectException: Connection refused: no further information: localhost/127.0.0.1:6379
Caused by: java.net.ConnectException: Connection refused: no further information
	at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
	at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:717)
	at io.netty.channel.socket.nio.NioSocketChannel.doFinishConnect(NioSocketChannel.java:327)
	at io.netty.channel.nio.AbstractNioChannel$AbstractNioUnsafe.finishConnect(AbstractNioChannel.java:336)
	at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:685)
	at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:632)
	at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:549)
	at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:511)
	at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:918)
	at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
	at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
	at java.lang.Thread.run(Thread.java:748)

解决方法

错误原因

自己电脑上没有安装好或者没有运行Redis服务。

安装Redis

1.下载Redis

https://pan.baidu/s/16ywP_dxuRDZu0KVs5hcwnw
密码:te3a
可以解压到任意文件夹下,解压后目录如下:

2.验证Redis安装成功与否

打开自己解压的文件夹,在空白处shift+鼠标右键找到菜单上:在此处打开命令行窗口;然后输入如下命令启动Redis服务器:

redis-server.exe redis.windows.conf --maxmemory 200M

如有必要,在前面加上“.\”,结果如下:

再启动Redis客户端,在同样目录下再打开一个新的命令行窗口,输入如下命令:

.\redis-cli.exe

结果如下:

到此,Redis已经成功安装。

3.把Redis服务添加到Windows服务中

在上述同样位置再打开一个命令行窗口,输入如下命令:

redis-server.exe --service-install redis.windows.conf --loglevel verbose

结果如下:

至此,说明Redis服务已经成功添加到Windows服务中了,以后启动就可以直接在Windows服务中启动了,而不用使用命令行窗口启动。

4.在Windows服务中启动Redis服务

右键我的电脑,单击管理。再右键Redis,启动服务。

在IDEA中添加Redis插件

在File–Settings–Plugins路径下,在Marketplace输入Iedis,然后下载,下载完成,重新启动IDEA。

然后再启动项目就不会出现错误了,能顺利登陆。

参考文章

  1. https://wwwblogs/arxive/p/9301512.html

本文标签: informationrefusedConnectionlocalhost