服务器之家:专注于服务器技术及软件下载分享
分类导航

PHP教程|ASP.NET教程|Java教程|ASP教程|编程技术|正则表达式|C/C++|IOS|C#|Swift|Android|VB|R语言|JavaScript|易语言|vb.net|

服务器之家 - 编程语言 - Java教程 - windows下使用 intellij idea 编译 kafka 源码环境

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

2022-02-23 00:49偶尔发呆 Java教程

这篇文章主要介绍了使用 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 源码环境

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

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

原文链接:https://www.cnblogs.com/allenwas3/p/9549915.html

延伸 · 阅读

精彩推荐