解决java.lang.NoClassDefFoundError: org/springframework/data/redis/connection/RedisStreamCommands

从 0 到 1:用 Trae 插件 Builder 模式开发端午包粽子小游戏 Trae插件的Builder模式为开发者提供了一种高效的项目搭建方式,通过自然语言描述需求,能够快速生成项目框架和核心代码,减少重复性工作。本文以开发端午包粽子小游戏为例,展示了Trae插件的安装、使用及功能特点。通过自然语言描述,插件能够理解并生成项目结构、代码文件,并提供开发路线图建议。在实际开发中,虽然自然语言描述的精准度对生成结果有影响,但Trae插件在代码生成效率和项目搭建速度上表现出色,尤其适合中小项目和特定类型应用的快速开发。未来,插件在复杂大型项目的高度定制化开发方面仍有提升空间。 阅读详情
AI摘要

本文讨论了在SpringBoot中使用Redisson时遇到的依赖冲突问题,主要原因是springboot2.3以上版本的redisson-starter不兼容低版本。解决方案是排除springboot2.3依赖并引入2.1版本的依赖。此外,新版redisson-starter允许直接在application.yml中配置Redisson,简化了配置过程。建议在遇到问题时,首先查看官方文档和源码,理解问题本质,避免盲目降级。

这是在 springboot 中使用 redisson 时,因为引入的依赖为

        <dependency>
            <groupId>org.redisson</groupId>
            <artifactId>redisson-spring-boot-starter</artifactId>
            <version>3.14.0</version>
        </dependency>

这个依赖,通过阅读源码,可以知道其中排除了默认的 jedis 以及 lettuce。参考 

package org.redisson.spring.starter;
包下的
RedissonAutoConfiguration 
类

由于redisson-starter 的支持随着 springboot 版本的调整也有所升级,因此最新版本的 starter 基本都是 springboot2.3的依赖。所以当我们使用 springboot2.3 以下的版本时,就会出现 classnotfound

 

解决方法:

排除springboot2.3 支持,引入 springboot2.1 支持。

        <dependency>
            <groupId>org.redisson</groupId>
            <artifactId>redisson-spring-boot-starter</artifactId>
            <version>3.14.0</version>
            <exclusions>
                <exclusion>
                    <groupId>org.redisson</groupId>
                    <artifactId>redisson-spring-data-23</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.redisson</groupId>
            <artifactId>redisson-spring-data-21</artifactId>
            <version>3.14.0</version>
        </dependency>

具体 springboot 支持参考官方文档

引申:

最新 redisson-starter 因为解决了 application.yml配置文件中直接配置 redisson 的问题,也就是说我们不用再编辑一个 redisson.yml的文件来配置 redisson,这解决了使用配置中心管理配置的尴尬。

spring:
    redis:
        database: 0
        password: password
        cluster:
          nodes: 127.0.0.1:7000,127.0.0.1:7001,127.0.0.1:7002
        # Redisson settings
        redisson:
        #      file: classpath:redisson.yaml
          config: |
            clusterServersConfig:
              idleConnectionTimeout: 10000
              connectTimeout: 10000
              timeout: 3000
              retryAttempts: 3
              retryInterval: 1500
              failedSlaveReconnectionInterval: 3000
              failedSlaveCheckInterval: 60000
              password: Index1130
              subscriptionsPerConnection: 5
              clientName: redisson
              loadBalancer: !<org.redisson.connection.balancer.RoundRobinLoadBalancer> {}
              subscriptionConnectionMinimumIdleSize: 1
              subscriptionConnectionPoolSize: 50
              slaveConnectionMinimumIdleSize: 50
              slaveConnectionPoolSize: 200
              masterConnectionMinimumIdleSize: 50
              masterConnectionPoolSize: 100
              readMode: "SLAVE"
              subscriptionMode: "SLAVE"
              nodeAddresses:
                  - "redis://127.0.0.1:7002"
                  - "redis://127.0.0.1:7001"
                  - "redis://127.0.0.1:7000"
              scanInterval: 1000
              pingConnectionInterval: 0
              keepAlive: false
              tcpNoDelay: false
            threads: 0
            nettyThreads: 0
            codec: !<org.redisson.codec.MarshallingCodec> {}
            transportMode: "NIO"
            lockWatchdogTimeout: 30000

源码:

@Bean(
        destroyMethod = "shutdown"
    )
    @ConditionalOnMissingBean({RedissonClient.class})
    public RedissonClient redisson() throws IOException {
        Config config = null;
        Method clusterMethod = ReflectionUtils.findMethod(RedisProperties.class, "getCluster");
        Method timeoutMethod = ReflectionUtils.findMethod(RedisProperties.class, "getTimeout");
        Object timeoutValue = ReflectionUtils.invokeMethod(timeoutMethod, this.redisProperties);
        int timeout;
        Method nodesMethod;
        if (null == timeoutValue) {
            timeout = 10000;
        } else if (!(timeoutValue instanceof Integer)) {
            nodesMethod = ReflectionUtils.findMethod(timeoutValue.getClass(), "toMillis");
            timeout = ((Long)ReflectionUtils.invokeMethod(nodesMethod, timeoutValue)).intValue();
        } else {
            timeout = (Integer)timeoutValue;
        }

        if (this.redissonProperties.getConfig() != null) {
            try {
                config = Config.fromYAML(this.redissonProperties.getConfig());
            } catch (IOException var13) {
                try {
                    config = Config.fromJSON(this.redissonProperties.getConfig());
                } catch (IOException var12) {
                    throw new IllegalArgumentException("Can't parse config", var12);
                }
            }
        } else if (this.redissonProperties.getFile() != null) {
            try {
                InputStream is = this.getConfigStream();
                config = Config.fromYAML(is);
            } catch (IOException var11) {
                try {
                    InputStream is = this.getConfigStream();
                    config = Config.fromJSON(is);
                } catch (IOException var10) {
                    throw new IllegalArgumentException("Can't parse config", var10);
                }
            }
        } else if (this.redisProperties.getSentinel() != null) {
            nodesMethod = ReflectionUtils.findMethod(Sentinel.class, "getNodes");
            Object nodesValue = ReflectionUtils.invokeMethod(nodesMethod, this.redisProperties.getSentinel());
            String[] nodes;
            if (nodesValue instanceof String) {
                nodes = this.convert(Arrays.asList(((String)nodesValue).split(",")));
            } else {
                nodes = this.convert((List)nodesValue);
            }

            config = new Config();
            ((SentinelServersConfig)config.useSentinelServers().setMasterName(this.redisProperties.getSentinel().getMaster()).addSentinelAddress(nodes).setDatabase(this.redisProperties.getDatabase()).setConnectTimeout(timeout)).setPassword(this.redisProperties.getPassword());
        } else {
            Method method;
            if (clusterMethod != null && ReflectionUtils.invokeMethod(clusterMethod, this.redisProperties) != null) {
                Object clusterObject = ReflectionUtils.invokeMethod(clusterMethod, this.redisProperties);
                method = ReflectionUtils.findMethod(clusterObject.getClass(), "getNodes");
                List<String> nodesObject = (List)ReflectionUtils.invokeMethod(method, clusterObject);
                String[] nodes = this.convert(nodesObject);
                config = new Config();
                ((ClusterServersConfig)config.useClusterServers().addNodeAddress(nodes).setConnectTimeout(timeout)).setPassword(this.redisProperties.getPassword());
            } else {
                config = new Config();
                String prefix = "redis://";
                method = ReflectionUtils.findMethod(RedisProperties.class, "isSsl");
                if (method != null && (Boolean)ReflectionUtils.invokeMethod(method, this.redisProperties)) {
                    prefix = "rediss://";
                }

                ((SingleServerConfig)config.useSingleServer().setAddress(prefix + this.redisProperties.getHost() + ":" + this.redisProperties.getPort()).setConnectTimeout(timeout)).setDatabase(this.redisProperties.getDatabase()).setPassword(this.redisProperties.getPassword());
            }
        }

        if (this.redissonAutoConfigurationCustomizers != null) {
            Iterator var19 = this.redissonAutoConfigurationCustomizers.iterator();

            while(var19.hasNext()) {
                RedissonAutoConfigurationCustomizer customizer = (RedissonAutoConfigurationCustomizer)var19.next();
                customizer.customize(config);
            }
        }

        return Redisson.create(config);
    }
# 当我们配置了spring.redis.redisson.config这个属性时,会优先以此属性为 redisson 配置
    if (this.redissonProperties.getConfig() != null) {
            try {
                config = Config.fromYAML(this.redissonProperties.getConfig());
            } catch (IOException var13) {
                try {
                    config = Config.fromJSON(this.redissonProperties.getConfig());
                } catch (IOException var12) {
                    throw new IllegalArgumentException("Can't parse config", var12);
                }
            }
        }

官方链接 配置

redisson 各种配置项以及集群 哨兵 单机配置,参考 redisson 官方文档 集群配置

 

由于目前网上,此类解决办法,全是千篇一律的直接降级 redisson-starter 的文章,希望各位朋友使用一个东西遇到问题的时候,首先看官方的 github,其次自己尝试阅读源码。当你选择降级的时候,你可能选择的是舍弃了最新的某些功能以及支持。

Redisson 3.50.0与Netty版本冲突?手把手教你排查依赖树并解决NoClassDefFoundError 本文详细解析了Redisson 3.50.0升级后常见的NoClassDefFoundError问题,其根源在于与Netty的版本依赖冲突。文章提供了从依赖树分析到解决方案的完整指南,包括如何识别缺失的Netty原生传输模块(如DomainSocketChannel),并通过统一版本、添加缺失依赖等方式彻底解决此问题。 阅读详情

相关推荐

Caused by: java.lang.NoSuchMethodError: org.springframework.data.redis.core.RedisTemplate.delete(Lja

Caused by: java.lang.NoSuchMethodError: org.springframework.data.redis.core.RedisTemplate.delete(Ljava/lang/Object;)V 核对redis版本 springboot版本

隔壁老瓦的专栏 2156

问题已解决 Caused by: java.lang.ClassNotFoundException: redis.clients.jedis.JedisPoolConfig

springboot中使用spring-data-redis出现Caused by: java.lang.ClassNotFoundException: redis.clients.jedis.JedisPoolConfig 在maven的配置如下: <dependency> <groupId>org.springframework.boot</gr...

u014089832的博客 1万+

STC32G电调调试血泪史:从TPH1R403NL MOS管烧毁到PWM信号异常排查全记录

本文详细记录了STC32G无刷电调调试过程中的常见问题与解决方案,包括MOS管烧毁、PWM信号异常等关键故障排查。通过电源系统检测、驱动电路验证及三相平衡调试等实战经验,帮助硬件爱好者快速定位问题,提升电调调试效率。特别针对TPH1R403NL等MOS管的保护措施进行了重点分析。

weixin_33736048的博客 551

解决SpringBoot启动报错:NoClassDefFoundError: org/springframework/data/redis/connection/RedisStreamCommands

22

dengchao1013的博客 1万+

小米汽车技术路线

从小米的电子电器架构来看,行业内EEA已经由域集中逐渐过度到域融合+区域控制的架构并向着中央计算+区域控制的方向发展。 而小米汽车智驾算法也从基于高精地图模块化架构,到去高精地图模块化架构,再到端到端架构,这也正是行业对于智驾算法演进的共识。

HITbingdu的博客 3785

用Python玩转ROS机械臂:YOLO目标检测+MoveIt!自动抓取仿真教程

本文详细介绍了如何利用Python集成YOLO目标检测与ROS的MoveIt!运动规划库,实现机械臂的智能抓取仿真。通过Gazebo仿真环境,从视觉感知、坐标转换到运动规划与执行,构建了一套完整的自动化抓取系统,为机器人视觉抓取应用提供了可复现的实践方案。

ppp33的博客 552

解决:java.lang.ClassNotFoundException: org.eclipse.jgit.api.TransportConfigCallback

在使用springcloud的config-server的时候报如下错误 错误提示: Exception in thread "main" java.lang.NoClassDefFoundError: org/eclipse/jgit/api/TransportConfigCallback at java.lang.Class.getDeclaredMethods0(Native Meth

东天里的冬天 5563

保姆级教程:用杰理701N可视化SDK搞定ANC降噪配置(从工具到代码全流程)

本文提供了一份详细的杰理701N可视化SDK配置ANC降噪功能的教程,涵盖从开发环境搭建到代码集成的全流程。通过图形化工具和代码示例,帮助开发者快速掌握ANC参数配置技巧,优化降噪效果,解决常见问题。

weixin_30616969的博客 450

java.lang.NoClassDefFoundError: org/springframework/data/redis/connection/SubscriptionListener

报错如下图,从图中明显可以看到服务已经启动成功,测试redis链接,请求都是正常的。但在启动后有一次发布链接超时,从报错信息上看 是订阅读取超时。研究了一番,发现是包有冲突的问题导致的。将引用的包拆分,不在使用redisson-spring-boot-starter,redisson 这个包是我项目中通过redis的延时关单机制,使用到的。redis发布订阅只需要用到常规的spring-data-redis包。

aayygg1234的专栏 2097

创意视觉项目实战:用ESP32-S3+OV5640构建智能图像流系统

本文详细介绍了如何使用ESP32-S3开发板与OV5640摄像头模块构建智能图像流系统。从硬件连接到软件配置,涵盖Arduino环境搭建、图像采集优化、WiFi视频流传输及外设集成,为开发者提供完整的实战指南,助力智能家居和机器人视觉项目开发。

tech5的博客 1291

cesium加载geotiff的 四种方法

本文介绍了在Cesium中加载GeoTIFF数据的两种主要方法。首先解析了核心前置知识,包括坐标系匹配、数据类型区分和性能优化。方法1详细演示了如何将RGB影像GeoTIFF转换为Cesium影像图层,包含从数据解析到Canvas转换的完整代码流程。方法2则针对高程数据(DEM)处理,展示了前端直接解析构建地形网格的方案。文章提供了完整的代码示例和关键实现要点,适用于卫星影像、专题图和数字高程模型等多种GeoTIFF数据类型在三维场景中的可视化需求。

大剑师兰特的GIS世界 395

SpringBoot 集成Redisson 提示:java.lang.ClassNotFoundException: **.redis.connection.ReactiveRedisConnec

SpringBoot 集成Redisson 提示如下错误信息: Caused by: java.lang.ClassNotFoundException: org.springframework.data.redis.connection.ReactiveRedisConnectionFactory SpirngBoot +Redisson 版本信息 名称 版本 SpringBoot 1.5.18 Redisson 3.13.6 错误Pom.xml 依赖 <

zhouzhiwengang的专栏 4376

Autosar诊断实战系列05-Dcm之0x27加解密服务配置开发详解

UDS 0x27服务实战开发介绍,对解锁尝试次数及delay时间进一步解释。

initiallizer的博客 1992

Spring-项目启动正常,打成jar包访问报错ClassNotFoundException:org.springframework.data.redis.connection.RedisStream

所以接下来去检查redisson的配置和pom文件中的依赖版本。所以,问题就找到了,redisson版本不匹配,所以我们排除掉SpringBoot2.5版本的redisson-spring-data,也就是redisson-spring-data-25,然后重新导入SpringBoot2.1版本的redisson-spring-data。而我们3.16.8版本的redisson依赖中的版本对应的是redisson-spring-data-25,也就是SpringBoot2.5版本。

努力搬砖,顶峰相见 1147

【TC3xx芯片】TC3xx芯片PFlash的ECC校验问题补充

TC3xx芯片PFlash的ECC校验问题补充

qq_36056498的博客 1153

廖雪峰Python教程[完整版]

廖雪峰的python教程整理的,已经排好版了,而且还是完整的,适合小白

2021-10-08关于redis报错java.long.classNotFoundException:org.springframework.data.redis.core.RedisTe

在开发部署服务器中遇见一个比较大意粗心的地方报错为(java.long.classNotFoundException:org.springframework.data.redis.core.RedisTe)。 我是通过打包为war包的形式上传到tomcat里面,后来需求需要添加一个redis的访问ip黑名单, 在本地测试redis增删查改的操作是能正常运行的,但部署上服务器就会报错,因为我是手动配置的jedis的xml文件所以手动了配置 账号密码端口,一开始我以为是我配置的问题,还有代码的问题,后来报错是j

gheost的博客 2895

数学建模模型总结

这是本人在两年内准备参加数学建模竞赛搜集到的模型资料,已经经过了本人的筛选和整理,希望能够对准备参加数学建模竞赛的学弟学妹们提供一些帮助!

redisson-spring-data 与spring-boot 版本冲突导致打包后找不到org/springframework/data/redis/connection/zset/* 下的类

2. 原因:redisson-spring-data 与spring-boot 版本冲突(spring-boot 版本2.6.11)。方案二:降低redisson-spring-boot-starter 版本。方案一: 重新引入redisson-spring-data。两种方法本地和打包后运行都正常。

qq_41157635的博客 4324

IDEA的使用指南

IDEA基于java的使用手册,可以最快速的上手,在使用中不断的丰富自己的使用技巧.

STM32F407中文手册

STM32f407中文手册 本参考手册面向应用开发人员,提供有关使用 STM32F405xx/07xx、STM32F415xx/17xx、 STM32F42xxx 和 STM32F43xxx 微控制器存储器与外设的完整信息。STM32F405xx/07xx、STM32F415xx/17xx、STM32F42xxx 和 STM32F43xxx 构成一个微 控制器系列,各产品具有不同的存储器大小、封装和外设。有关订购信息以及器件的机械与电气特性,请参见数据手册。有关 ARM Cortex™-M4F 内核的信息,请参见《Cortex™-M4F 技术参考手册》。

java.lang.NoClassDefFoundError: org/springframework/data/redis/connection/zset/Tuple

Linux 环境报很多时候是依赖版本差异或类路径问题导致的。通过分析依赖结构与版本关系,最终将降级到兼容版本,问题得以解决。

hanlepeng的博客 1397

redis报ClassNotFoundException...redis/connection/lettuce/LettuceClientConfiguration$LettuceClientConf

springboot工程整合redis时因为版本不一致导致如此错误:org/springframework/data/redis/connection/lettuce/LettuceClientConfiguration$LettuceClientConfigurationBuilder得具体解决办法

Feify博客 9295

spring-boot 项目打包后运行 org/springframework/data/redis/connection/zset/Tuple 错误

妈蛋,jenkins 部署发现启动不了,各种清理都不行,换了 jenkins 上的 maven 版本,清了所有依赖重新拉,都不行。把 redisson-spring-boot-starter 3.18.1 降到 3.17.4 就好了。结果 3.18.1 兼容了本地运行,没兼容打包后的运行,找了我几大个小时一点一点的排查错误。前两天刚把 springboot 2.5.14 升级了 2.7.10。然后试本地打包运行,我去,一直以为是部署问题,结果本地也不行。本地直接启动正常,结果打包后出现问题。

ws - 兮的博客空间 9361

ClassNotFoundException问题集

这是因为我在项目中引入了dev的热键部署引起的 删除即可!!

weixin_47081743的博客 687

Spring Boot集成Redis启动失败【Caused by: java.lang.ClassNotFoundException: org.apache.commons.pool2.impl.G】

Spring Boot集成Redis启动失败【Caused by: java.lang.ClassNotFoundException: org.apache.commons.pool2.impl.GenericObjectPoolConfig】

专注Java后端技术干货、项目源码总结分享,期待您的关注。 3188

java.lang.ClassNotFoundException异常问题原因总结

常会遇到报找不到类的问题,有时是没有引入相关类,但很多时候明明是有的,现把原因简单总结如下: 1、java.lang.ClassNotFoundException: com.alibaba.nacos.client.logging.NacosLogging 调试spring cloud alibaba总报这个错,查到对应包nacos-client-2.0.3有此类,双击无法打开,果断判断是包下载问题,去仓库删除下载包,maven重新下载,搞定! 2、还有一种常见的报错原因是引入了不同版本的包,两个包都

u011017880的专栏 5万+

使用Spring Boot与Redis集成报错 NoClassDefFoundError...RedisConnectionFactory

使用Spring Boot与Redis集成时出现java.lang.NoClassDefFoundError: org/springframework/data/redis/connection/RedisConnectionFactory 最近按照教程指引,给Spring应用加入了授权领英账号登录的界面。 接着准备与Redis集成,也就是将登录的用户信息存储到分布式数据库Redis中...

程序员小辰的代码小窝 1万+
上一篇: 面试相关-List总结
Model_Vincent
博客等级 码龄9年 1粉丝 23原创
评论 4
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值