我目前的开发过程是改Java代码,mvn包,ant更新,重启我的tomcat服务器。我真的很希望能够添加断点,并实时调试我的 DSpace 实例。我最近遇到了一个海洋链接代码的问题,想调试,但不得不求助于 println / log info 来查看变量。
我熟悉 wiki 页面:https ://wiki.duraspace.org/display/DSPACE/IDE+Integration+-+DSpace+and+IDEA
我只是想知道是否有关于该主题的更简洁的最新指导。
我目前的开发过程是改Java代码,mvn包,ant更新,重启我的tomcat服务器。我真的很希望能够添加断点,并实时调试我的 DSpace 实例。我最近遇到了一个海洋链接代码的问题,想调试,但不得不求助于 println / log info 来查看变量。
我熟悉 wiki 页面:https ://wiki.duraspace.org/display/DSPACE/IDE+Integration+-+DSpace+and+IDEA
我只是想知道是否有关于该主题的更简洁的最新指导。
我创建了一个视频演练,描述了我们在 IDEA 中的开发人员设置: https ://www.youtube.com/watch?v=mrLl1qPsy6I
在视频快结束时,它显示了要部署的模块以及如何安排上下文路径。
距离上一个视频不到两年,终于有调试视频了: https ://www.youtube.com/watch?v=V5Zi71zYmf8
视频中未涵盖的一项超级强大的功能是“评估表达”。当程序在断点处暂停时,您可以使用“评估表达式”对程序的当前状态执行任意方法调用。
Bram has provided an excellent tutorial on this topic, the one other strategy I can recommend that can sometimes be faster to setup is Remote Debugging.
The goal is to get into a "remote debug mode" on your existing deployed DSpace webapp in tomcat or in the DSpace CLI. Then you can attach to it directly without configuring embedded tomcat in Intellij. This is great because it can be completed locally using localhost or remotely over the network against an existing development server hostname/IP.
Copy first text boxes settings into env settings to your tomcat or CLI instance.
-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005
4.a. For DSpace CLI in [DSACE_HOME]/bin/dspace add the following line just prior to the java command (note we set suspend to y to assure that we have an opportunity to connect to the debugging port before the application executes.
export JAVA_OPTS="$JAVA_OPTS -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005"
4.b For Tomcat Configuration export env settings already provided in tomcat catalina.sh script to start tomcat in debug mode. (note we set suspend to n to allow tomcat to start properly.
export JPDA_OPTS=-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005
%TOMCAT_HOME%/bin/catalina.sh jpda start
Once you have started the CLI app or Tomcat, then you can connect your configured debug settings. First select your Debug config from the Run/Debug dropdown on the toolbar and start in debug mode using the "Debug" icon.
This will connect to the debug port (if you have problems check for firewall restrictions). You should now be able to set breakpoints and step through your code in Intellij while it is executing on the server.
Caveats are that you will need to complete the entire mvn build/ant deploy to get any of your changes into the running tomcat/cli application. For faster developer turnaround, it is best to run the war/cli directly in intellij and using Bram's tutorial is excellent for that purpose. However, when this is not possible, this is a great alternative to be able to debug on existing live test sites.
Cheers, Mark