0%

Win 10 ElasticSearch源码本地调试

如何在本地调试ElasticSearch源码?



下载代码

此处以我平时学习的代码为例

1
git clone git@github.com:jiankunking/elasticsearch.git

导入到Idea

原文地址:https://github.com/jiankunking/elasticsearch/blob/master/CONTRIBUTING.md

Idea 代码运行

Debug Elasticsearch是idea导入代码后自动有的,但要注意下图红框1、2两处配置

https://discuss.elastic.co/t/failing-to-run-on-intellij-in-debug-mode/227805/3

本地代码运行

cd到代码根目录

执行如下命令

1
./gradlew run --debug-jvm

看到界面显示如下

表示代码已经启动完成

请求调用

这时候就可以在idea代码中添加断点了

1
2
curl --location 'http://localhost:9200' \
--header 'Authorization: Basic ZWxhc3RpYzpwYXNzd29yZA=='

返回

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
{
"name": "runTask-0",
"cluster_name": "runTask",
"cluster_uuid": "7OO9ktkiRp29frL6VYDzGg",
"version": {
"number": "8.0.0-SNAPSHOT",
"build_flavor": "default",
"build_type": "zip",
"build_hash": "886e154d5d08d33a33c734c2961c6917b528925e",
"build_date": "2023-06-08T01:37:09.815840600Z",
"build_snapshot": true,
"lucene_version": "8.8.0",
"minimum_wire_compatibility_version": "7.12.0",
"minimum_index_compatibility_version": "7.0.0"
},
"tagline": "You Know, for Search"
}

欢迎关注我的其它发布渠道