7

I am trying to change the default mvnDebug port - can anyone walk me through the steps to do this? I have tried resetting MAVEN_DEBUG_OPTS, but this has not worked for me. Thanks so much!

Sally L
  • 83
  • 1
  • 4
  • Possible duplicate of [Debugging in maven with mvnDebug command](https://stackoverflow.com/questions/29310760/debugging-in-maven-with-mvndebug-command) – glytching Nov 02 '17 at 08:27
  • I think [Debugging in Maven](https://stackoverflow.com/questions/29310760/debugging-in-maven-with-mvndebug-command?noredirect=1&lq=1) can help you, asking for the same. – Charmy Garg Nov 07 '17 at 07:19

4 Answers4

3
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
z atef
  • 7,138
  • 3
  • 55
  • 50
2

You can change your port in mvnDebug.bat

set MAVEN_OPTS=-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000

or if you want to set through command line you can copy mvnDebug.bat to newMvnDebug.bat by commeting out the line

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

and then try setting MAVEN_DEBUG_OPT via command line

Charmy Garg
  • 291
  • 2
  • 14
0

On Linux none of the given answers worked on my Ubuntu 16.04.

The specified port was ignored:

$ 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

One solution was to use the following command:

$ 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
Stephane
  • 11,836
  • 25
  • 112
  • 175
0

you can just set the env variable MAVEN_DEBUG_ADDRESS if you need only to change the port (maven 3.9.0)

Wafa
  • 146
  • 3
  • 9