更改默认的mvnDebug端口

时间:2017-11-01 23:59:52

标签: maven

我正在尝试更改默认的mvnDebug端口 - 是否有人可以指导我执行此操作的步骤?我已经尝试重置MAVEN_DEBUG_OPTS,但这对我没用。非常感谢!

3 个答案:

答案 0 :(得分:2)

您可以在 mvnDebug.bat

中更改您的端口
set MAVEN_OPTS=-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000

或者如果你想通过命令行设置,你可以通过纪念行来复制mvnDebug.bat到newMvnDebug.bat

MAVEN_DEBUG_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000

然后尝试通过命令行设置 MAVEN_DEBUG_OPT

答案 1 :(得分:2)

For MAc users: 


* find the file:

za$ locate  mvnDebug   
/usr/local/Cellar/maven@3.3/3.3.9/bin/mvnDebug
/usr/local/Cellar/maven@3.3/3.3.9/libexec/bin/mvnDebug
/usr/local/bin/mvnDebug



* Open the file for editing, change the port and save:

za$ vim /usr/local/Cellar/maven@3.3/3.3.9/libexec/bin/mvnDebug
#!/bin/sh

MAVEN_DEBUG_OPTS="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000"

echo Preparing to Execute Maven in Debug Mode

env MAVEN_OPTS="$MAVEN_OPTS" MAVEN_DEBUG_OPTS="$MAVEN_DEBUG_OPTS" $(dirname $0)/mvn "$@"
~

~
~


# changed mine ot 8080 and test:
za$  /usr/local/bin/mvnDebug
Preparing to Execute Maven in Debug Mode
Listening for transport dt_socket at address: 8080

答案 2 :(得分:0)

在Linux上,给出的答案均不适用于我的Ubuntu 16.04。

指定的端口被忽略:

$ export MAVEN_DEBUG_OPTS="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005"
[stephane@stephane-ThinkPad-X201 user-rest]
$ mvnDebug clean install -Denv="test" -Ddb="h2" 
Preparing to execute Maven in debug mode
Listening for transport dt_socket at address: 8000

一种解决方案是使用以下命令:

$ mvn clean install -Denv="test" -Ddb="h2" -Dmaven.surefire.debug="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005 -Xnoagent -Djava.compiler=NONE"
...
[INFO] -------------------------------------------------------
[INFO] Listening for transport dt_socket at address: 5005