美文网首页
解决 springBoot 集成 Redis 出现的: Unab

解决 springBoot 集成 Redis 出现的: Unab

作者: 童话破灭i | 来源:发表于2022-10-31 13:05 被阅读0次

    报错如下:

    org.springframework.data.redis.RedisConnectionFailureException: Unable to connect to Redis; nested exception is io.lettuce.core.RedisConnectionException: Unable to connect to 192.168.136.222:6379	at org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory$SharedConnection.getNativeConnection(LettuceConnectionFactory.java:1189)	at org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory$SharedConnection.getConnection(LettuceConnectionFactory.java:1168)	

    解决办法:

    1. 查看有没有启动 Redis 服务器。

    2. redis 的配置 application.yml(或 application.properties)中
      spring.redis.timeout 连接超时时间(毫秒)中设置不能为 0, 一般修改如下:spring.redis.timeout=5000。

    3. 找到 redis 的配置文件 redis.conf : 执行 vim redis.conf
      3.1 protected-mode yes 改为 protected-mode no (即该配置项表示是否开启保护模式,默认是开启,开启后 Redis 只会本地进行访问,拒绝外部访问)。
      3.2 注释掉 bin127.0.0.1 即 #bin 127.0.0.1 (ps: 不注释掉,表示指定 redis 只接收来自于该 IP 地址的请求,注释掉后,则表示将处理所有请求)。

    4. 如果在 Redis 中没有配置 requirepass , 那么在 application.properties(或 application.yaml) 中就不要写 spring.redis.password。

    相关文章

      网友评论

          本文标题:解决 springBoot 集成 Redis 出现的: Unab

          本文链接:https://www.haomeiwen.com/subject/wpvrtdtx.html