问题描述
可以使用Eclipse附加到正在运行的应用程序,类似于使用Visual Studio附加的应用程序吗?
是的。 / p>
如果您启动调试端口打开的服务器,请将其添加到您的java命令中:
-Xdebug -Xrunjdwp:transport = dt_socket,address = 127.0.0.1:8888,server = y,suspend = n
您的项目中有源代码(从技术上讲,这不是必需的,除非你这样做),你可以通过设置一个debug来连接到正在运行的服务器配置
与主机=服务器正在运行的机器和端口= 8888(例如 - 参见上面的选项)
然后您可以设置断点和调试会话将停止服务器,您可以检查变量/字段,甚至设置其值。
更新
JV的更现代的命令行选项M这样做是
-agentlib:jdwp = transport = dt_socket,address = 127.0.0.1:8888,server = suspend = n
Can you attach to a running application using Eclipse, similar to how you attach using Visual Studio?
Yes.
If you start your server with the debug port open, by adding this into your java command:
-Xdebug -Xrunjdwp:transport=dt_socket,address=127.0.0.1:8888,server=y,suspend=n
And you have the source code in your project (technically this isn't required, but it's kind of useless unless you do), you can connect to the running server by setting up a "debug configuration"with host = the machine the server is running on and port = 8888 (for example - see options above)
You can then set break points and the debug session will halt the server there and you can inspect variables/fields, and even set their values.
Update
The more modern command-line options for the JVM to do this are
-agentlib:jdwp=transport=dt_socket,address=127.0.0.1:8888,server=y,suspend=n
这篇关于使用Eclipse将调试器附加到应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!