windows下使用 intellij idea 编译 kafka 源码环境

 更新时间:2021年10月20日 08:33:57   作者:偶尔发呆  
这篇文章主要介绍了使用 intellij idea 编译 kafka 源码的环境,本文是基于windows下做的项目演示,需要的朋友可以参考下

1. 从 GitHub 网站,git clone kafka 源码

2. 下载安装好 gradle,scala

  2.1 从 dependencies.gradle 文件中找到 gradle 的版本,然后下载指定版本,并配置好 GRADLE_HOME 环境变量

3. 进入 kafka 项目目录,依次执行 gradle wrapper,gradle idea,gradle build --exclude-task test

4. 将工程导入到 idea

  4.1 启动主类 kafka.Kafka

  4.2 program arguments:config/server.properties

  4.3 把 config 目录下的 log4j.properties 拷贝到 core/src/main/resources 目录

  4.4 File -> Project Structure -> Modules

5. 启动程序

然而,大部分情况下,日志不会打印出来,配置一下 core 模块的 log4j 依赖

找到 build.gradle 文件中的 project(':core'),修改对应的 log4j 依赖,然后重新执行  gradle idea,重新导入 idea 中

project(':core') {
  println "Building project 'core' with Scala version ${versions.scala}"

  apply plugin: 'scala'
  
  // scaladoc generation is configured at the sub-module level with an artifacts
  // block (cf. see streams-scala). If scaladoc generation is invoked explicitly
  // for the `core` module, this ensures the generated jar doesn't include scaladoc
  // files since the `core` module doesn't include public APIs.
  scaladoc {
    enabled = false
  }
  if (userEnableTestCoverage)
    apply plugin: "org.scoverage"
  archivesBaseName = "kafka_${versions.baseScala}"

  dependencies {
    compile project(':clients')
    compile project(':metadata')
    compile project(':raft')
    compile libs.argparse4j
    compile libs.jacksonDatabind
    compile libs.jacksonModuleScala
    compile libs.jacksonDataformatCsv
    compile libs.jacksonJDK8Datatypes
    compile libs.joptSimple
    compile libs.metrics
    compile libs.scalaCollectionCompat
    compile libs.scalaJava8Compat
    compile libs.scalaLibrary
    // only needed transitively, but set it explicitly to ensure it has the same version as scala-library
    compile libs.scalaReflect
    compile libs.scalaLogging
    compile libs.slf4jApi
    compile libs.slf4jlog4j
    compile libs.log4j

    compile(libs.zookeeper) {
//      exclude module: 'slf4j-log4j12'
//      exclude module: 'log4j'
    }
    // ZooKeeperMain depends on commons-cli but declares the dependency as `provided`
    compile libs.commonsCli

    compileOnly libs.log4j

    testCompile project(':clients').sourceSets.test.output
    testCompile libs.bcpkix
    testCompile libs.mockitoCore
    testCompile libs.easymock
    testCompile(libs.apacheda) {
      exclude group: 'xml-apis', module: 'xml-apis'
      // `mina-core` is a transitive dependency for `apacheds` and `apacheda`.
      // It is safer to use from `apacheds` since that is the implementation.
      exclude module: 'mina-core'
    }
    testCompile libs.apachedsCoreApi
    testCompile libs.apachedsInterceptorKerberos
    testCompile libs.apachedsProtocolShared
    testCompile libs.apachedsProtocolKerberos
    testCompile libs.apachedsProtocolLdap
    testCompile libs.apachedsLdifPartition
    testCompile libs.apachedsMavibotPartition
    testCompile libs.apachedsJdbmPartition
    testCompile libs.junitJupiter
    testCompile libs.slf4jlog4j
    testCompile(libs.jfreechart) {
      exclude group: 'junit', module: 'junit'
    }
  }

目标就是把下图的 log4j 依赖配置好。

到此这篇关于windows下使用 intellij idea 编译 kafka 源码环境的文章就介绍到这了,更多相关 idea 编译 kafka 源码内容请搜索脚本之家以前的文章或继续浏览下面的相关文章希望大家以后多多支持脚本之家!

相关文章

  • Spring Boot的Maven插件Spring Boot Maven plugin详解

    Spring Boot的Maven插件Spring Boot Maven plu

    Spring Boot的Maven插件Spring Boot Maven plugin以Maven的方式提供Spring Boot支持,Spring Boot Maven plugin将Spring Boot应用打包为可执行的jar或war文件,然后以通常的方式运行Spring Boot应用,本文介绍Spring Boot的Maven插件Spring Boot Maven plugin,一起看看吧
    2024-01-01
  • Java并发之原子性 有序性 可见性及Happen Before原则

    Java并发之原子性 有序性 可见性及Happen Before原则

    一提到happens-before原则,就让人有点“丈二和尚摸不着头脑”。这个涵盖了整个JMM中可见性原则的规则,究竟如何理解,把我个人一些理解记录下来。下面可以和小编一起学习Java 并发四个原则
    2021-09-09
  • 一文搞懂Spring中Bean的生命周期

    一文搞懂Spring中Bean的生命周期

    这篇文章主要为大家介绍了Spring中Bean生命周期的使用及控制,文中的示例代码讲解详细,对我们学习或工作有一定的参考价值,感兴趣的可以学习一下
    2022-06-06
  • SpringBoot如何实现文件下载

    SpringBoot如何实现文件下载

    这篇文章主要介绍了SpringBoot如何实现文件下载问题,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教
    2023-11-11
  • POI XSSFSheet shiftRows bug问题解决

    POI XSSFSheet shiftRows bug问题解决

    这篇文章主要介绍了POI XSSFSheet shiftRows bug问题解决,有需要的朋友可以借鉴参考下,希望能够有所帮助,祝大家多多进步,早日升职加薪
    2023-07-07
  • Hibernate中使用HQLQuery查询全部数据和部分数据的方法实例

    Hibernate中使用HQLQuery查询全部数据和部分数据的方法实例

    今天小编就为大家分享一篇关于Hibernate中使用HQLQuery查询全部数据和部分数据的方法实例,小编觉得内容挺不错的,现在分享给大家,具有很好的参考价值,需要的朋友一起跟随小编来看看吧
    2019-03-03
  • Springboot传参详解

    Springboot传参详解

    这篇文章主要介绍了Springboot传参的相关知识,本文通过实例代码给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友参考下吧
    2023-11-11
  • Spring Native实现0.059s启动一个SpringBoot项目

    Spring Native实现0.059s启动一个SpringBoot项目

    Spring Native是Spring框架的一个子项目,旨在提供一种将Spring应用程序编译为本地可执行文件的方法,从而提高启动时间和资源效率,本文主要介绍了Spring Native实现0.059s启动一个SpringBoot项目,感兴趣的可以了解一下
    2024-02-02
  • Java实现短信验证码的示例代码

    Java实现短信验证码的示例代码

    Java是一种流行的编程语言,验证码是一种常用的网络安全技术。Java发展至今,网上也出现了各种各样的验证码,下面是用Java实现短信验证码的总结,感兴趣的可以了解一下
    2023-03-03
  • SpringBoot整合分布式锁redisson的示例代码

    SpringBoot整合分布式锁redisson的示例代码

    这篇文章主要介绍了SpringBoot整合分布式锁redisson,本文结合实例代码给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友可以参考下
    2023-02-02

最新评论