如何使用 Visual Studio Code 附加到远程 Java 调试器

如何使用 Visual Studio Code 附加到远程 Java 调试器

问题描述:

我正在尝试配置 Visual Studio Code,以便我可以使用它代替 IJ 来调试复杂的 Java 应用程序.由于太复杂的原因,我一直在使用 mvnDebug 在终端上运行,然后使用 JDB 连接.在 IJ 中,我将其设置为远程调试器,但是,我似乎无法在 VSC 中找到相同的选项.

I am trying to configure Visual Studio Code so that I can use it instead of IJ for debugging a complex Java app. Because of reasons too complicated to get into, I have been running on a terminal using mvnDebug then connecting using JDB. In IJ I set this up as a remote debugger, however, I can't seem to find the same option in VSC.

尝试了这个扩展,但我不知道如何只为 JDB 配置它(我不应该需要 startupClass 等).

I have tried this extension, but I can't figure out how to configure it for just JDB (I shouldn't need startupClass etc).

如何将 JDB 与 Visual Studio Code 结合使用?

How do I use JDB with Visual Studio Code?

创建如下调试配置并按F5进行调试:

Create a Debug Configuration like below and press F5 to debug :

"version": "0.2.0",
"configurations": [
    {
        "type": "java",
        "name": "Debug (Attach)",
        "projectName": "Your_Project_Name",
        "request": "attach",
        "hostName": "your_host_name",
        "port": Debugging_port
    }
]

示例:

"version": "0.2.0",
"configurations": [
    {
        "type": "java",
        "name": "Debug (Attach)",
        "projectName": "MyApplication",
        "request": "attach",
        "hostName": "localhost",
        "port": 8787
    }
]

我使用的是wildfly 服务器.所以默认调试端口是8787.

I am using wildfly server. So the default debugging port is 8787.