windows下使用 intellij idea 編譯 kafka 源碼環(huán)境
1. 從 GitHub 網站,git clone kafka 源碼
2. 下載安裝好 gradle,scala
2.1 從 dependencies.gradle 文件中找到 gradle 的版本,然后下載指定版本,并配置好 GRADLE_HOME 環(huán)境變量
3. 進入 kafka 項目目錄,依次執(zhí)行 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 依賴,然后重新執(zhí)行 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 源碼環(huán)境的文章就介紹到這了,更多相關 idea 編譯 kafka 源碼內容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關文章希望大家以后多多支持腳本之家!
相關文章
使用ByteArrayOutputStream實現將數據寫入本地文件
這篇文章主要介紹了使用ByteArrayOutputStream實現將數據寫入本地文件,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教2021-12-12
簡單了解Spring beanfactory循環(huán)依賴命名重復屬性
這篇文章主要介紹了簡單了解Spring beanfactory循環(huán)依賴命名重復2大屬性,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友可以參考下2020-06-06
Mybatis-Plus讀寫Mysql的Json字段的操作代碼
這篇文章主要介紹了Mybatis-Plus讀寫Mysql的Json字段的操作代碼,文中通過實例代碼給大家介紹的非常詳細,對大家的學習或工作具有一定的參考借鑒價值,需要的朋友可以參考下2022-04-04
java SpringBoot自定義注解,及自定義解析器實現對象自動注入操作
這篇文章主要介紹了java SpringBoot自定義注解,及自定義解析器實現對象自動注入操作,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2020-08-08
Springboot整合企業(yè)微信機器人助手推送消息的實現
本文主要介紹了Springboot整合企業(yè)微信機器人助手推送消息的實現,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧2022-05-05
使用ServletUtil.write方法下載接口文件中文亂碼問題解決
本文主要介紹了使用ServletUtil.write方法下載接口文件中文亂碼問題解決,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧2024-05-05
基于Properties類操作.properties配置文件方法總結
這篇文章主要介紹了Properties類操作.properties配置文件方法總結,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教2021-09-09

