更新时间:2023-11-10 10:24:40
解决方案是在MAVEN_OPTS中将其更改为 suspend = y
而不是n 。然后,您执行 mvn jetty:run
命令,它会在Listing for transport dt_socket at address:4000行中暂停。之后,您运行eclipse调试器,它将附加到该进程。
如果使用suspend = n,它将无法正常工作(至少对我来说't)。
I am trying to debug a Maven jetty project in eclipse. I am staring jetty using "mvn clean jetty:run". Here's the complete bat file I'm using (I'm on windows).
set MAVEN_OPTS="-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=4000,server=y,suspend=n"
mvn clean jetty:run
I am using the jetty-maven-plugin inside the pom file.
The bat file works ok and starts jetty without errors. Inside eclipse, I created a new debug configuration, chose "Remote Java Application" and I used 4000 for the port and localhost for the host.
When I try to run this debug configuration, I always get this error:
"Failed to connect to remote VM. Connection refused.
Connection refused: connect"
Does anyone know how I can solve this? I checked this answer, but it did not help.
The solution was that you have to change it to suspend=y
instead of n in the MAVEN_OPTS. Then you do the mvn jetty:run
command, and it will pause at the "Listening for transport dt_socket at address: 4000" line. After that, you run the eclipse debugger and it will attach to the process.
If you use suspend=n, it won't work (at least for me it didn't).