解决netty-socketio依赖问题

在一个项目中用到netty-socketio碰到一个问题,有新手碰到这个问题可能会纠结不少时间,写出来以供参考,有碰到类似问题的也可以节省点儿时间。。

在项目源码编译时报错,错误截图如下

Paste_Image.png

错误信息显示 io.netty.util.internal.PlatformDependent

反编译netty-transport-4.1.5.Final 的代码可以看到

ChannelOutboundBuffer 里有一行代码 如下

AtomicIntegerFieldUpdater unwritableUpdater = PlatformDependent.newAtomicIntegerFieldUpdater(ChannelOutboundBuffer.class, "unwritable");

PlatformDependent 是在netty-common-4.1.5.Final的包,同样反编译查看源码,并没有发现newAtomicLongFieldUpdater 这样一个方法。

同样4.1.5.final 的包竟然出现方法找不到的问题,这个不会是坑爹专用版吧???

找到netty-all-4.1.5.Final 看了下源码 发现 ChannelOutboundBuffer的实现已经完全不一样了。

索性把netty的分包的依赖全部替换掉, 修改maven的pom文件

 <dependency>
      <groupId>com.corundumstudio.socketio</groupId>
      <artifactId>netty-socketio</artifactId>
      <version>1.7.13</version>
      <exclusions>
        <exclusion>
          <groupId>io.netty</groupId>
          <artifactId>netty-common</artifactId>
        </exclusion>
        <exclusion>
          <groupId>io.netty</groupId>
          <artifactId>netty-transpor</artifactId>
        </exclusion>
        <exclusion>
          <groupId>io.netty</groupId>
          <artifactId>netty-buffer</artifactId>
        </exclusion>
        <exclusion>
          <groupId>io.netty</groupId>
          <artifactId>netty-handler</artifactId>
        </exclusion>
        <exclusion>
          <groupId>io.netty</groupId>
          <artifactId>netty-codec-http</artifactId>
        </exclusion>
        <exclusion>
          <groupId>io.netty</groupId>
          <artifactId>netty-codec</artifactId>
        </exclusion>
        <exclusion>
          <groupId>io.netty</groupId>
          <artifactId>netty-resolver</artifactId>
        </exclusion>
        <exclusion>
          <groupId>io.netty</groupId>
          <artifactId>netty-transport</artifactId>
        </exclusion>
        <exclusion>
          <groupId>io.netty</groupId>
          <artifactId>netty-transport-native-epoll</artifactId>
        </exclusion>
      </exclusions>
</dependency>

自己引入netty-all的依赖


<dependency>
      <groupId>io.netty</groupId>
      <artifactId>netty-all</artifactId>
      <version>4.1.16.Final</version>
 </dependency>

好了, 这样就不会有问题了

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • Android 自定义View的各种姿势1 Activity的显示之ViewRootImpl详解 Activity...
    passiontim阅读 173,403评论 25 708
  • Spring Boot 参考指南 介绍 转载自:https://www.gitbook.com/book/qbgb...
    毛宇鹏阅读 46,958评论 6 342
  • 当听到电话那头你哭鼻子,还能哭得那么凶的时候,我就笑了,难道你就真的长不大? 然后脑子了响起齐一在《致自己》中唱到...
    萤火虫de梦阅读 104评论 0 0
  • 老字号的港式餐厅,由于某种原因我对它格外钟爱。餐厅环境干净利落,沿袭了港式茶餐厅的一贯传统。菜品推荐:冰火菠萝油、...
    鹿肉串烧阅读 277评论 0 0
  • 不知道天使会不会特别眷顾哭泣的女孩,让她的泪滴也能开花结果,绚丽绽放。 还记得那年,我也曾随手在课本上写...
    一切都好lmy阅读 273评论 0 1