Gradle gretty jetty 在调试中不工作

Gradle gretty jetty not working in Debug

我正在使用 Windows OS、JDK 1.7、Gradle 3.0、IDE Eclipse mars 和 jetty 8.1.5.v20120716。

注意:我也在用gretty插件

gretty {
    port = http_port
    host = '127.0.0.1'
    contextPath = ''
    classPath = sourceSets.main.resources.srcDirs
    servletContainer = 'jetty9' //tomcat7 or tomcat8
     httpPort = 8081 
     servicePort = 8082 
     statusPort = 8083
}

我尝试过的所有选项的行为都是相同的,它只是挂在端口 5005 语句上,它甚至没有加载应用程序。我正在使用基于 Spring 注释和 class 类型的初始值设定项 "AbstractAnnotationConfigDispatcherServletInitializer"

我尝试了以下选项。 appStartDebug、appRunDebug、jettyStartDebug 和 jettyRunDebug。

C:\project>echo %GRADLE_OPTS%
-Xdebug -Xrunjdwp:transport=dt_socket,address=9999,server=y,suspend=n

C:\project>gradle jettyStartDebug
Listening for transport dt_socket at address: 9999
Starting a Gradle Daemon, 10 busy and 19 stopped Daemons could not be reused, use --status for details
'5e5ca94'
:prepareInplaceWebAppFolder UP-TO-DATE
:createInplaceWebAppFolder UP-TO-DATE
:compileJava UP-TO-DATE
:processResources UP-TO-DATE
:classes UP-TO-DATE
:prepareInplaceWebAppClasses UP-TO-DATE
:prepareInplaceWebApp UP-TO-DATE
:jettyStartDebug
Listening for transport dt_socket at address: 5005

请有人帮我解决这个问题。

%GRADLE_OPTS% 中删除调试选项并执行

gretty {
    debug = true
    debugSuspend = false
    debugPort = 9999
    ...
}

StartBaseTask.groovy and AppStartTask.groovy

您必须创建一个远程调试会话。

在 eclipse 中:运行 > 调试配置 > 远程 Java 应用程序 然后右键单击并创建新的。暂不启动。

然后转到控制台并使用以下命令启动您的项目:gradle jetty运行调试,当它在 "Listening for transport dt_socket at address: 5005" 停止时,从 IDE 开始启动您的调试,使用之前创建的配置。

它必须进入调试模式。