在 Jetty 中调试 gradle 网络应用程序

Debugging gradle web application in Jetty

我是 Gradle 的新手。我在 Eclipse 中使用 Buildship。我的 build.gradle 看起来像,

gretty {
    httpPort = 8080
    contextPath = '/'
    servletContainer = 'jetty9'
}

当我调试应用程序时,'gretty -> appStartDebug',控制台等待说,

Listening for transport dt_socket at address: 5005

我的项目是一个 init 为的 Web 应用程序,

@WebServlet(urlPatterns="/InitServlet", loadOnStartup=0)
public class InitServlet extends HttpServlet {
}

public static void initialize() {
 system.out.println("Initializing");
}

我在 sysout 中有我的断点。这是调试 gradle 应用程序的正确方法吗?

控制台正在等待您的调试器进程连接到套接字。

  1. 在 Eclipse 中新建 remote debugging session
  2. 执行gradle任务appStartDebug并等待消息:

    Listening for transport dt_socket at address: 5005

  3. 运行 您之前在 Eclipse 中配置的远程调试配置

  4. 停止使用 gradle 任务调试 Web 应用程序 appStop

阅读更多信息以及如何在 IntelliJ IDEA 中进行调试here