天天看点

搭建redis完成后项目无法连接[nested exception is io.lettuce.core.RedisConnectionException: Unable to connect ]

1 搭建redis并启动成功后,项目连接失败 -1 项目配置: -1.1 如果在搭建redis时,没有设置redis密码,那么在项目中配置文件(application.properties/application.yml)配置文件中不需要配置password -1.2 spr…

1 搭建redis并启动成功后,项目连接失败

-1 项目配置:

-1.1 如果在搭建redis时,没有设置redis密码,那么在项目中配置文件(application.properties/application.yml)配置文件中不需要配置password

搭建redis完成后项目无法连接[nested exception is io.lettuce.core.RedisConnectionException: Unable to connect ]

-1.2 spring boot 项目 配置文件中,spring.redis.timeout 配置的时间不能为0

搭建redis完成后项目无法连接[nested exception is io.lettuce.core.RedisConnectionException: Unable to connect ]

-2 redis 配置

-2.1 查看redis是否启动

ps aux | grep redis-server

启动成功

搭建redis完成后项目无法连接[nested exception is io.lettuce.core.RedisConnectionException: Unable to connect ]

redis未启动,切换到redis的bin目录下:

./redis-server ../redis.conf

ps:

如果配置redis时,自定了启动配置文件,需要在./redis-server 后面跟上自定义配置文件所在位置

-2.2 查看redis redis.conf配置文件中几个数据是否设置正确

-2.2.1 protected-mode yes 修改为no ps:该配置表示是否开启保护模式,如果为yes,则该redis只允许本地发起连接

搭建redis完成后项目无法连接[nested exception is io.lettuce.core.RedisConnectionException: Unable to connect ]

-2.2.2 bind 127.0.0.1 该行需要注释掉,如果不注释掉,则表示redis只接受该ip地址的请求,注释掉,则可以接受任意ip的请求

搭建redis完成后项目无法连接[nested exception is io.lettuce.core.RedisConnectionException: Unable to connect ]

-2.2.3 timeout 根据自己的需求,调整大小,默认设置为0,无法连接

搭建redis完成后项目无法连接[nested exception is io.lettuce.core.RedisConnectionException: Unable to connect ]