
springboot 配置 redis 报 connection reset 错误
在 springboot 3.x 版本中配置 redis 客户端时,部分用户遇到了终端提示 “connection reset” 的错误。虽然数据看似可以写入 redis(出现乱码),但读出后为空。
出现此问题的原因是:
redis 版本不兼容:redis 3.x 版本存在该问题。
解决方法:
挖错网
一款支持文本、图片、视频纠错和AIGC检测的内容审核校对平台。
28 查看详情
升级 redis 版本至 5.x 以上:目前已测试,在升级到 redis 5.x 版本后,不再出现 “connection reset” 错误。
配置范例:
// pom.xml org.springframework.data spring-data-redis 3.4.3// application.propertiesspring.redis.host=localhostspring.redis.port=6379
示例代码:
@SpringBootApplicationpublic class Application { public static void main(String[] args) { SpringApplication.run(Application.class, args); } }@RestControllerpublic class Controller { @Autowired private RedisTemplate redisTemplate;@GetMapping("/") public String index() { redisTemplate.opsForValue().set("key", "value"); return "Hello, World!"; } }
以上就是SpringBoot 3.x 配置Redis连接重置错误:如何解决Redis版本不兼容问题?的详细内容,更多请关注创想鸟其它相关文章!
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。
如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 chuangxiangniao@163.com 举报,一经查实,本站将立刻删除。
发布者:程序猿,转转请注明出处:https://www.chuangxiangniao.com/p/378674.html
微信扫一扫
支付宝扫一扫