idea源码注释乱码_2020最新Netty4.1.55.Final源码阅读环境搭建

本文档详细介绍了在Windows环境下使用IntelliJ IDEA搭建Netty 4.1.55.Final源码阅读环境的步骤,包括环境配置、源码下载、导入IDEA以及解决编译过程中的签名错误、代码风格校验失败、日志乱码和API不兼容等问题。同时提供了运行EchoServer和EchoClient的指南。
摘要由CSDN通过智能技术生成

一、源码阅读环境搭建

1.环境信息

  • 机器环境:win10 64位
  • Oracle Java8 : 1.8.0_251
  • 开发工具:IntelliJ IDEA
  • netty源码版本: netty-4.1.55.Final

2.下载源码

下载代码,可以用gitee加速

git clone https://github.com/netty/netty.git

切换到指定分支

git checkout netty-4.1.55.Final

3.导入idea cmd

3.1 使用idea直接打开源码目录

提前配置好idea新建工程的maven配置

3.2在maven的profile中勾选如下,导入后没改过

e5b177ae70e6cfeda7652e85f475fbe9.png
image-20201212002057649.png

3.3 执行install

点击图标让mvn跳过测试(test就会显示删除线)。再双击install进行编译

5f9879059d147e41d2120c92f09de985.png
image-20201211221448198.png
3.3.1 netty-common 编译签名错误

Failed to execute goal org.codehaus.mojo:animal-sniffer-maven-plugin:1.16:check (default) on project netty-common: Signature errors found. Verify them and ignore them with the proper annotation if needed.

按提示可以选择注释animal-sniffer-maven-plugin

6afc9c7d0dfae99ebb37f65924b7c5a7.png
image-20201211234421107.png
3.3.2 代码风格校验失败

Failed to execute goal org.apache.maven.plugins:maven-checkstyle-plugin:3.1.0:check (nohttp-checkstyle-validation) on project netty-parent: You have 1 Checkstyle violation.

直接注释掉:maven-checkstyle-plugin

6e9e1f5b8a2c82ccbc5b4dea84b59763.png
image-20201211234906643.png
3.3.3 报错java: 对assertEquals的引用不明确

netty-transport 编译抱错,但是idea显示日志乱码

通过在控制台执行命令netty\transport>mvn -DskipTests=true install,发现错误日志如下:

对assertEquals的引用不明确
Assert 中的方法 assertEquals(long,long) 和 Assert 中的方法 assertEquals(Object,Object) 都匹配

有报错的地方直接加强转,官网master就是这么干的

//PendingWriteQueueTest.java:263:9
assertEquals(1L, (long) channel.readOutbound());
//ByteToMessageCodecTest.java:65:9
assertEquals(1, (int) ch.readInbound());
//ByteToMessageDecoderTest.java:505:9
assertEquals((byte) 1, (byte) channel.readInbound());
//ChunkedWriteHandlerTest、FlushConsolidationHandlerTest

3.3.4 netty-codec-http 检测Api不兼容

Failed to execute goal com.github.siom79.japicmp:japicmp-maven-plugin:0.14.3:cmp (default) on project netty-codec-http: There is at least one incompatibility: io.netty.handler.codec.http.multipart.AbstractDiskHttpData:METHOD_ABSTRACT_ADDED_IN_IMPLEMENTED_INTERFACE,io.netty.handler.codec.http.multipart.AbstractMemoryHttpData:METHOD_ABSTRACT_ADDED_IN_IMPLEMENTED_INTERFACE

那就跳过检查,把false改为true

51d364e40f4519611c7144a88ee237b2.png
image-20201212001742889.png

4.运行EchoServer和EchoClient

完整类名io.netty.example.echo.EchoServer,io.netty.example.echo.EchoClient

4.1 EchoServer运行日志

ab6b918e6f657aadf88bc124cf96f65c.png
image-20201212003245018.png

4.2 运行时可以有选择的把Client和Server的日志打印Handler取消注释

6d320177f831347a87a6f7d1c40c6e37.png
image-20201212002725591.png

R1.参考资料

https://segmentfault.com/a/1190000022319237?utm_source=tag-newest

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值