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>
Logo

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。

更多推荐