spring boot redis和netty5.0.0冲突

本文介绍了一个关于Spring Boot Redis与Netty 5.0.0 Alpha1版本之间的兼容性问题。当同时引入这两个依赖时,应用启动失败。问题在于Spring Boot Redis引入的lettuce与Netty的不同版本之间存在冲突。解决方案是在引入common模块时排除lettuce-core。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

spring boot redis和netty5.0.0冲突

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-redis</artifactId>
        </dependency>
        <dependency>
            <groupId>io.netty</groupId>
            <artifactId>netty-all</artifactId>
            <version>5.0.0.Alpha1</version>
        </dependency>

启动的时候会出现如下错误:

***************************
APPLICATION FAILED TO START
***************************

Description:

An attempt was made to call the method io.netty.bootstrap.Bootstrap.channel(Ljava/lang/Class;)Lio/netty/bootstrap/Bootstrap; but it does not exist. Its class, io.netty.bootstrap.Bootstrap, is available from the following locations:

    jar:file:/F:/repository/io/netty/netty-transport/4.1.29.Final/netty-transport-4.1.29.Final.jar!/io/netty/bootstrap/Bootstrap.class
    jar:file:/F:/repository/io/netty/netty-all/5.0.0.Alpha1/netty-all-5.0.0.Alpha1.jar!/io/netty/bootstrap/Bootstrap.class

It was loaded from the following location:

    file:/F:/repository/io/netty/netty-transport/4.1.29.Final/netty-transport-4.1.29.Final.jar

问题分析:
spring-boot-starter-data-redis 引入了lettuce,
而lettuce又关联了

        <!-- Netty -->

        <dependency>
            <groupId>io.netty</groupId>
            <artifactId>netty-common</artifactId>
        </dependency>

        <dependency>
            <groupId>io.netty</groupId>
            <artifactId>netty-transport</artifactId>
        </dependency>

        <dependency>
            <groupId>io.netty</groupId>
            <artifactId>netty-handler</artifactId>
        </dependency>

maven结构说明:
common模块引入的 spring-boot-starter-data-redis、netty-all
biz模块引入common模块
xxx模块,引入common模块、biz模块

解决思路:
xxx模块引入common模块时,排除lettuce-core即可!

        <dependency>
            <groupId>com.xxx.xxx</groupId>
            <artifactId>common</artifactId>
             <exclusions>
                 <exclusion>
                     <groupId>io.lettuce</groupId>
                     <artifactId>lettuce-core</artifactId>
                 </exclusion>
             </exclusions>
        </dependency>
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

西京刀客

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值