zoukankan      html  css  js  c++  java
  • spring boot 集成 redis 出现 “Unable to connect to localhost:6379”

    当访问到代码

    redisTemplate.opsForValue();

    时,出现以下错误:

    org.springframework.data.redis.RedisConnectionFailureException: Unable to connect to Redis; nested exception is io.lettuce.core.RedisConnectionException: Unable to connect to localhost:6379
    at org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory$SharedConnection.getNativeConnection(LettuceConnectionFactory.java:1092) ~[spring-data-redis-2.1.5.RELEASE.jar:2.1.5.RELEASE]
    at org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory$SharedConnection.getConnection(LettuceConnectionFactory.java:1065) ~[spring-data-redis-2.1.5.RELEASE.jar:2.1.5.RELEASE]
    at org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory.getSharedConnection(LettuceConnectionFactory.java:865) ~[spring-data-redis-2.1.5.RELEASE.jar:2.1.5.RELEASE]
    at org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory.getConnection(LettuceConnectionFactory.java:340) ~[spring-data-redis-2.1.5.RELEASE.jar:2.1.5.RELEASE]
    at org.springframework.data.redis.core.RedisConnectionUtils.doGetConnection(RedisConnectionUtils.java:132) ~[spring-data-redis-2.1.5.RELEASE.jar:2.1.5.RELEASE]
    at org.springframework.data.redis.core.RedisConnectionUtils.getConnection(RedisConnectionUtils.java:95) ~[spring-data-redis-2.1.5.RELEASE.jar:2.1.5.RELEASE]
    at org.springframework.data.redis.core.RedisConnectionUtils.getConnection(RedisConnectionUtils.java:82) ~[spring-data-redis-2.1.5.RELEASE.jar:2.1.5.RELEASE]
    at org.springframework.data.redis.core.RedisTemplate.execute(RedisTemplate.java:211) ~[spring-data-redis-2.1.5.RELEASE.jar:2.1.5.RELEASE]
    at org.springframework.data.redis.core.RedisTemplate.execute(RedisTemplate.java:184) ~[spring-data-redis-2.1.5.RELEASE.jar:2.1.5.RELEASE]
    at org.springframework.data.redis.core.AbstractOperations.execute(AbstractOperations.java:95) ~[spring-data-redis-2.1.5.RELEASE.jar:2.1.5.RELEASE]
    at org.springframework.data.redis.core.DefaultValueOperations.get(DefaultValueOperations.java:53) ~[spring-data-redis-2.1.5.RELEASE.jar:2.1.5.RELEASE]

    【参考】

    https://xinghua24.github.io/SpringBoot/Spring-Boot-Spring-Data-Redis/

    https://github.com/xinghua24/SpringBootExamples/tree/master/data-redis
    Need to add @EnableRedisRepositories annotation and create beans for connection factory and redisTemplate


    【解决】

     

     

  • 相关阅读:
    [图形学] 结束 [Unity Shader] 开始
    [图形学] Chp18 OpenGL表面纹理函数
    [图形学] Chp17 OpenGL光照和表面绘制函数
    [图形学] Chp14 GLU曲面裁剪函数程序示例及样条表示遗留问题
    [图形学] Chp10 OpenGL三维观察程序示例
    [图形学] 问题: 裁剪窗口坐标对应显示窗口中像素是一对一还是一对多?
    [图形学] Chp9 三维几何变换--栈处理函数与矩阵管理函数的区别
    [图形学] 习题8.12 NLN二维线段裁剪算法实现
    [图形学] 习题8.6 线段旋转后使用Cohen-Sutherland算法裁剪
    [图形学] Chp8 使用双缓存创建帧动画
  • 原文地址:https://www.cnblogs.com/yisa/p/15192101.html
Copyright © 2011-2022 走看看