Intellij idea搭建solr7.7源码debug调试环境

clone代码

git clone https://github.com/apache/lucene-solr.git

下载后阅读根目录下README.md。

下载ant依赖

如果本地没有安装过ant的请自行安装。

在项目根目录下执行命令

ant ivy-bootstrap

自动下载ant依赖包。第一次执行需要较长时间,显示BUILD SUCCESSFUL则成功。

这一步只需要执行一次,后面不需重复执行。

ant项目转换成maven项目

项目根目录下执行命令

ant idea

注意:执行完此步骤才可以用intellj idea打开项目。未转换先打开了会有问题。

编译项目

进入项目根目录 solr/ 目录,执行命令

ant server

idea运行solr server

在idea上运行solr server是实际启动的是embedSolrServer。

  • 先准备一个solr_home,放在solr/server/ 目录下

  • 在项目 solr/solrj/src/test/org/apache/solr/client/solrj/StartSolrJetty.java 中增加上面准备的solr_hom的路径;设置webapp war路径

    Intellij idea搭建solr7.7源码debug调试环境_第1张图片

  • solr/solrj/src/resources 目录下添加log4j2配置文件(solr/solrj/src/resources/log4j2.xml)

  • run StartSolrJetty.java,然后访问 localhost:8983/solr

    Intellij idea搭建solr7.7源码debug调试环境_第2张图片

    Intellij idea搭建solr7.7源码debug调试环境_第3张图片

  • 对源码打断点,debug StartSolrJetty.java 即可进行源码调试

导入自定义jar

如果有基于源码自定义的插件jar,也可以把插件代码导入到源码项目中进行debug。


Intellij idea搭建solr7.7源码debug调试环境_第4张图片

原文 http://qianjiasong.com/post/solr-debug-idea-build/

你可能感兴趣的:(Intellij idea搭建solr7.7源码debug调试环境)