JAVA.LANG.NOSUCHMETHODERROR:io.netty.buffer.PooledByteBufAllocator.defaultNumHeapArena()I

spark + scala开发过程中,遇到了netty版本冲突或包缺失导致的error,参考解决办法:

  1. 在终端中进入项目根目录,也就是pom文件所在的目录,运行
mvn dependency:tree
  1. 随即找到netty所处的包:
[INFO] |  +- org.apache.hadoop:hadoop-hdfs:jar:2.6.0-cdh5.15.1:compile
[INFO] |  |  +- io.netty:netty:jar:3.10.5.Final:compile

  1. 在指定依赖中添加:
			<dependency>
            <groupId>org.apache.hadoop</groupId>
            <artifactId>hadoop-client</artifactId>
            <version>${hadoop.version}</version>
            <!--将netty包排除-->
            <exclusions>
                <exclusion>
                    <groupId>io.netty</groupId>
                    <artifactId>netty</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
  1. 然后添加高版本netty:
<!--解决io.netty.buffer.PooledByteBufAllocator.defaultNumHeapArena()I异常,-->
        <dependency>
            <groupId>io.netty</groupId>
            <artifactId>netty-all</artifactId>
            <version>4.1.18.Final</version>
        </dependency>
发布了294 篇原创文章 · 获赞 73 · 访问量 1万+

猜你喜欢

转载自blog.csdn.net/weixin_43777983/article/details/104558048