当前位置: 首页 > 知识库问答 >
问题:

java - Spring 2 到 Spring 3 迁移后 Redis 报错 NOAUTH 错误的原因及解决?

贺宏逸
2025-02-14

Spring2 转到 Spring3 后整合 Redis 报错 NOAUTH Authentication required

我在spring boot 2.7.3中使用SpringDataRedis正常运行。

但在spring boot 3.4.0中使用就会报错NOAUTH Authentication required.

Redis版本: 3.2.100-windows版

依赖:

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>

配置类:

@Configuration
public class RedisConfiguration {

    @Bean
    public RedisTemplate redisTemplate(RedisConnectionFactory redisConnectionFactory) {
        RedisTemplate redisTemplate = new RedisTemplate<>();

        // 设置 Redis 的连接工厂对象
        redisTemplate.setConnectionFactory(redisConnectionFactory);
        // 设置 Redis key 的序列化器
        redisTemplate.setKeySerializer(new StringRedisSerializer());

        return redisTemplate;
    }

}

spring boot 3.4.0 的 application (相较于2.7.3增加了data):

# Redis 主机地址
spring.data.redis.host=localhost
# Redis 端口号
spring.data.redis.port=6379
# Redis 密码
spring.data.redis.password=123456
# Redis 指定数据库
spring.data.redis.database=1

redis.windows.conf中将密码注释,并注释 application 中的spring.data.redis.password=123456后,能够成功运行。

猜测是因为 spring 版本太高而 redis 版本太低的原因?

共有1个答案

苏野
2025-02-14

redis 3.0 版本仅支持 RESP2 的通信协议,而 Lettuce 6.x 版本开始,使用 RESP3(Redis 6.x 引入)的 HELLO 命令进行版本自适应判断,但是对于不支持 HELLO 命令的低版本实例,兼容性存在一定问题。刚好 springboot 版本默认的引入的 redis 客户端是 lettuce 6.x ,协议不通。

 类似资料:
  • 我正在做一个项目,在Spring-MVC项目中添加一些Ajax。我取下了标签 这样就会在JSP中插入错误,现在我正在尝试制作一些Ajax代码来在页面上显示错误。请问谁应该我如何更新下面的代码来显示错误信息而不是错误? 公共类JsonResponse{private String status=Null;private Object result= 公共字符串getStatus(){return s

  • 问题内容: 我正在使用hibernate插入到所有表均定义为非null的mysql表中。它有一个唯一的主键,并在几列上有另一个唯一的索引。 我收到以下错误: org.springframework.dao.DataIntegrityViolationException:无法执行JDBC批处理更新。SQL [插入MY_TABLE(col1,col2,col3,col4,ID_)值(?,?,?,?,?

  • 当我尝试使用将android项目迁移到时,我收到一条错误消息。 错误信息 目前,以下库正在使用。 莫西 刀柄 房间 <代码>构建。渐变 有关更多详细信息,回购托管在此处-https://github.com/Abhimanyu14/finance-manager

  • 当我尝试启动我的应用程序时,我的 MainActivity 在 oncreate() 方法中的“setContentView(R.layout.activity_main);” 中抛出此错误: 这个错误出现在迁移到androidx之后,经过进一步检查,我注意到Bottomnavigationview类中的导入语句已经过时(没有androidx格式,而是旧格式)。Bottomnavigationvi

  • 我正在尝试将我的应用程序服务器(JBOSS EAP)从6.4迁移到7.4.3。但是,迁移后,我在访问我的网络服务时收到以下错误。 立即展开:org。阿帕奇。cxf。拦截器。错误:解组错误:意外元素(uri:…)原因:com。太阳istack。SAXParseException2;行号:0;列数:0;意外元素(uri:…) 同样的请求在JBOSS EAP 6.4中运行得非常好。但在迁移之后,它现在不

  • 嗨,我正在尝试升级到wagtail 2.0。我已经处理了一系列错误,但我无法克服迁移时出现的错误: 非常感谢任何帮助 谢谢 提姆 完全控制台错误: (wagtail-isa) MacBook-Air:wagtailcmsdemo tim$ ./manage.py makemigrations Traceback(最近一次调用最后一次):文件“./manage.py”,第 10 行,在 execut

  • 我用试用密钥尝试了State/BaselineMigration功能。https://flywaydb.org/documentation/concepts/baselinemigrationsFlyWay迁移执行脚本并正确移动到正确的版本。但在此基础上运行的所有迁移都失败了 从S开始2__xxx.sql然后它在版本2的模式表中创建一行并键入"SQL_STATE_SCRIPT" 再次执行flywa

  • 本文向大家介绍MySQL 出现错误1418 的原因分析及解决方法,包括了MySQL 出现错误1418 的原因分析及解决方法的使用技巧和注意事项,需要的朋友参考一下 MySQL 出现错误1418 的原因分析及解决方法 具体错误:  使用mysql创建、调用存储过程,函数以及触发器的时候会有错误符号为1418错误。 ERROR 1418 (HY000): This function has none