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


    【解决】

     

     

  • 相关阅读:
    (转)Hibernate框架基础——在Hibernate中java对象的状态
    (转)Hibernate框架基础——cascade属性
    (转)Hibernate框架基础——多对多关联关系映射
    (转)Hibernate框架基础——一对多关联关系映射
    (转)Hibernate框架基础——映射集合属性
    (转)Hibernate框架基础——映射主键属性
    (转)Hibernate框架基础——映射普通属性
    (转)Eclipse在线配置Hibernate Tools
    人物志---川航8633事件
    日常英语---200204(moderately)
  • 原文地址:https://www.cnblogs.com/yisa/p/15192101.html
Copyright © 2011-2022 走看看