如何使用 Visual Studio Code 附加到远程 Java 调试器 [英] How do attach to a remote Java debugger using Visual Studio Code

查看:47
本文介绍了如何使用 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.

这篇关于如何使用 Visual Studio Code 附加到远程 Java 调试器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆