I read this: Debugging in Maven?
I\'m running intellij remote debug and maven for a service I\'m trying to debug.
I\'m running
mvnDebug tom
Wow, Maven makes this difficult. Setting -Xrunjdwp in MAVEN_OPTS won't work, because mvnDebug.bat adds its own afterward, which will override MAVEN_OPTS. I would copy mvnDebug.bat to myMvnDebug.bat and comment out the line set MAVEN_DEBUG_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000. That way you can set MAVEN_DEBUG_OPT on the command line before running it.
C:\somewhere>set MAVEN_DEBUG_OPT=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8001
C:\somewhere>myMvnDebug.bat
I changed @set MAVEN_DEBUG_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
to
@set MAVEN_DEBUG_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=%MAVEN_DEBUG_PORT%
in mvnDebug.cmd then either set MAVEN_DEBUG_PORT in env variables or locally with set @set MAVEN_DEBUG_OPTS=8001 before you call mvnDebug xxx:run (I'm using Jetty)