简体   繁体   中英

Debug Solr code in Eclipse

New to Eclipse and Solr, I imported apache-solr-3.6.0.war into Eclipse and run Solr with tomcat plugin. Now i want to debug some existing code, however how do i import the Solr source code?

Without knowing how you imported it exactly: sounds like you are looking for Source attachment .

It might be better if you use the Solr source code directly. Check the README file included in the release, there is an ant task to init eclipse:

To setup your ide run [...] 'ant eclipse'.

Then all dependencies are loaded using ivy and you can run it from within the IDE.

You can also check out the whole Lucene/Solr source:

  1. install Subclipse add-in
  2. choose New... > Project...
  3. SVN > Checkout projects from SVN...
  4. add this link as new repository
  5. select branch /branches/lucene_solr_3_6 (if you want last stable version. Use trunk if you want to use cutting edge source)
  6. choose Check out as a project in a workspace and leave everything else default

Then, after the checkout completes, to complete setup, you don't have to fiddle with JARs manually, simply:

  1. right click on main build.xml , the one in your project's root
  2. choose Run As... > Ant build... select (in this order)
  3. ivy-bootstrap and resolve tasks (which will download all JAR dependencies)
  4. then run in this order: validate, clean-idea, eclipse, compile, get-maven-poms, generate-maven-artifacts (the last two only if you plan to use Maven).

And that's it, you should now see no redness in your workspace and have Lucene and Solr JARs built.

Run solr like this:

java -jar -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=1044 start.jar

Solr will start, but wait you to connect from Eclipse to continue.

Then in Eclipse, go to:

  1. Run / Debug Configurations...
  2. Select Remote Java Application
  3. Press New button to create a new remote configuration
  4. put 1044 on port
  5. Click on Debug

This is the standard way to debug remote applications in Java

./solr start -p 8983 -f -a "-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=0.0.0.0:8000"

Start solr with

  1. provide app run on port 8983
  2. provide Xrunjdwp:transport=dt_socket
  3. remote ip address 0.0.0.0:8000 and then go to eclipse eclipse 中的 solr 调试模式配置

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM