有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java应用程序打印“侦听地址为5005的传输dt_socket”,并且不会停止

我使用典型参数开始代码执行:

java -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005 myPackage.myMainClassname

应用程序启动,打印“侦听地址为5005的传输dt_socket”并。。。更进一步!没有任何等待连接的尝试。我可以在执行和调试过程中连接到它。但是为什么应用程序不等待来自调试器的连接呢

看起来我的配置有问题,但我无法找出根本原因。我尝试了几种方法来指定调试设置、不同的端口、以管理员身份运行、关闭防火墙——没有任何帮助


共 (2) 个答案

  1. # 1 楼答案

    Select menu "Run/Edit Configurations". Check: "Edit configurations" dialog pops up. Click on "+" icon, select "Remote" from the list. Check: new configuration with name "Unnamed" appears under "Remote" category. Change configuration name to something more sensible, like "Remote Debug". Don't change any other parameters, just click "OK".

    Run web-application under the debugger

    Start gradle task "appStartDebug" under IntelliJ IDEA. Attention: do not try to start this task under the debugger. Run it in normal mode. Check: you should see "Listening for transport dt_socket at address: 5005" in "Run" output window. Select menu "Run/Run...", select "Remote Debug" configuration, select "Debug" command. Check: you should see "Connected to the target VM, address: 'localhost:5005', transport: 'socket'" in "Debug" output window.

    现在您的web应用程序正在调试器下运行:您 可以设置断点、监视/检查变量等

  2. # 2 楼答案

    如果希望它等待连接,则需要指定suspend=y。您的调试正在工作。如果你尝试连接,你将能够。很可能您只是习惯于使用suspend=y,它会阻塞直到建立连接

    suspend=n时应出现该行为