Launch / Debug ElasticSearch in IntelliJ

Is there any way to debug ElasticSearch server in real time from IntelliJ? I have no experience with Maven. My goal is to run it while I can debug it and check the variables and the thread of execution.

+7
java intellij-idea maven elasticsearch
source share
2 answers

Ok, found it. Use the IntelliJ Run menu to add a new launch configuration.

  • Run
  • Change configuration
  • +
  • Install Main class in org.elasticsearch.bootstrap.Bootstrap
  • Set VM options to -Des.foreground = yes

Voila. Loans

+8
source share

You did not specify whether you want to debug / log into the Elastic Search (ES) client or break the code.

Client code

As long as the sources are connected, yes, you can debug it. If you use Maven, you can ask it to download (and attach) sources, assuming they are available in the Maven Central repository . (Elastic Search deploys its sources in the central center of maven, so you should be good there. If not, you will have to "manually" attach the source jar in the "Project Structure" dialog box.)

To download and attach maven, open the maven tool window and click the "Download ..." button enter image description here and select "Download Sources" or "Download Sources and Documentation." Now, IDEA will load and attach all available JAR source files (and / or javadoc) for all dependencies / libraries in your project. If you wish, you can configure maven for this. To set it for the current project, click the settings button enter image description here in the maven tool window and select "Import" node or select "Settings"> "Project Settings"> "Maven"> "Import". In the dialog box, check the Automatic Download options and / or documentation. To set this default value for all future projects that you create, go to File> Other Settings> Default Settings> Maven> Import and configure.

After the sources are connected, you can enter the search code or open one of the classes: 1) using Ctrl + N to search and enter the class, typing Ctrl + N a second time to include library classes in your search, or 2) with using Ctrl + B (when the cursor is on a method call) or Ctrl + Click to go to the method declaration. Then you can set breakpoints.

For server code

You will need to create an elastic search project with source code. The easiest way would be to clone their repo (or otherwise check). You can also simply attach ES server libraries (including sources) to your project.

If you are performing elasticity searches locally, simply create a local Run / Debug configuration to launch ES and run through Debug. If you run ES on a remote server, you will need to create a remote debug configuration and then connect to the remote ES server (which will need to be started with the proper Java Debug properties.) See Help> IntelliJ IDEA> Help> Dialog> Startup Configurations / Debugging> Startup / Debugging Configuration: Remote and Help> IntelliJ IDEA> Language and Framework Guides> Java EE> Working with Application Servers> Working with Server Startup / Debugging Configurations for more information.

+2
source share

All Articles