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


    【解决】

     

     

  • 相关阅读:
    word 快捷键
    java中的各种修饰符作用范围
    pinyin4j的基本使用
    022-pinyin4j工具类模板
    测开之路一百四十五:SQLAlchemy与后台模板整合之新增、查询、删除
    测开之路一百四十四:ORM之SQLAlchemy查询
    测开之路一百四十三:ORM框架之SQLAlchemy模型及表创建
    测开之路一百四十二:ORM框架之SQLAlchemy建库、建表、数据库操作
    测开之路一百四十一:蓝图实现程序模块化
    测开之路一百四十:可拔插视图(基于类、基于方法)
  • 原文地址:https://www.cnblogs.com/yisa/p/15192101.html
Copyright © 2011-2022 走看看