Use eclispe to debug Kafka source code

I am optimistic about Scala. After all, Kafka and Spark are so awesome that you can’t do it without them, so Scala will definitely become popular!

After watching Scala for 2 weeks, and using Kafka for several years, I can finally download the source code of Kafka and see who it is!

environment:

Window 10

Scala 2.11.8

Eclipse mar2

JDK 1.8

gradle-2.13


Kafka:

kafka-0.8.2.0-src


In other words, it's just a quick installation, and there isn't much.

The installation of gradle is relatively simple. Set the environment variable: GRADLE_HOME=d:/dev/gradle-2.13 and then add %GRADLE_HOME%\bin to PATH. That's it. You can configure the JDK in the same way.

I won’t mention the installation of Scala, but don’t forget to install the scala plug-in in eclipse. This is also easy to do!


The most important thing among them is to modify the configuration file: kafka-0.8.2.0-src/gradle.properties. Otherwise, there would be various Scala version errors and Java class path errors, and I would be at a disadvantage here!

Be sure to modify the following Scala version to the currently used version:

scalaVersion=2.11.8

After changing this, enter the directory: execute gradle eclipse under kafka-0.8.2.0-src to generate the eclipse project (the network is not good, this process is relatively long, you can drink water and go to the toilet), the other is to import, Of course, when importing, just select an existing project, and then you can happily look at the code and debug wherever you want!


Haha, if the scala version is not consistent with your environment, various errors will occur. In the end, you will definitely find the following two BUGs (actually not BUGs):


https://issues.apache.org/jira/browse/KAFKA-1874

https://issues.apache.org/jira/browse/KAFKA-1873



Supongo que te gusta

Origin blog.csdn.net/zhangzhaokun/article/details/51523438
Recomendado
Clasificación