Use Intellij idea to build a solr debugging environment

Recently, when using solr, there will be some configuration problems. The log is printed out, but I still don't know the reason for such an error. So I want to learn the relevant solr source code. The following are the steps on how to build a solr debugging environment.

 

To build a solr debugging environment, first download the source code.

  The source code of each version can be downloaded from http://archive.apache.org/dist/lucene/solr/. You can also download the latest solr code on github at: https://github.com/jeniss/lucene-solr.

 

Import the source code into Intellij idea

  After downloading the solr project, it can be found that it is managed by ant. So you need to make sure that ant is installed. Ant download address: http://ant.apache.org/bindownload.cgi. Configure ant in environment variables. ANT_HOME: D:\Program Files (x86)\java\apache-ant-1.9.7, Path: %ANT_HOME%\bin. After the configuration is complete, execute ant -version to display the ant version, which means the installation is successful. As shown.

technology sharing

  Next, the solr source code is compiled into an idea project.

  In the root directory, run the ant command to see what ant can do.

technology sharing

  When we execute ant idea, the solr source code can be compiled into a project of intellij idea. It may fail when compiling ant idea, it is possible to run ant ivy-bootstrap.

  After the compilation is successful, import it through open in intellij idea. After selecting the "lucene-solr" parent project, the project is imported as a whole.

technology sharing -> technology sharing

  At this point, the project imports intellij idea.

 

Configuring JDPA Remote Debugging

  As of 5.3, solr no longer provides war packages. The solr team says: "Solr is intended to be a  server  not a  Java web application ". Therefore, in the \lucene-solr\solr directory, run ant server to create the solr server. The default root directory of solr cores is \lucene-solr\solr\server\solr.

  Then, configure remote debugging in idea. Add Remote in "Run Configurations", in the configuration, customize Name, Host, and Port. Transport selects the socket option.

technology sharing

  Next, we enter the lucene-solr\solr\bin folder in cmd and run solr start -p 8988 -f -a "-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8988" , the configured port number (eg 8988) should be the same as the port number configured in idea.

  Finally, run debug mode in idea. We are in the web page http://localhost:8988, we can start debugging.

 

View solr log files in Intellij idea

  In order to view the solr log file more conveniently, you can configure the following to view the log in idea.

  Add \lucene-solr\solr\server\logs\solr.log file to Debug Configurations.

technology sharing

  Modify the \lucene-solr\solr\server\resources\log4j.properties file to customize the content of the log output. When debugging remotely, the log displayed in the idea is as follows:

technology sharing

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326756599&siteId=291194637
Recommended