How to remote debug java application from maven command line

11,403

You can use remote debugging:

mvn exec:exec -Dexec.executable="java" -Dexec.args="-classpath %classpath -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=1044 com.mycompany.app.App"

Then in your eclipse, you can use remote debugging and attach the debugger to localhost:1044. Or configure the goals to debug configuration, create "Maven build" debug config:

Goals = -Dmaven.surefire.debug test
Profiles = myconfigprofile,weblogic

or for a specific TestSuite:

Goals = -Dmaven.surefire.debug -Dtest=com.myorg.mypkg/MyTestSuite.java test
Profiles = myconfigprofile,weblogic

Create additional "Remote Java Application" config:

Host = localhost Port = 5005

You can find more documentation here: http://maven.apache.org/surefire/maven-surefire-plugin/examples/debugging.html

Share:
11,403
Rakesh Gourineni
Author by

Rakesh Gourineni

Updated on June 06, 2022

Comments

  • Rakesh Gourineni
    Rakesh Gourineni about 2 years

    I have a java application running in IntelliJ. Can I know how to remote debug the application from maven command line.

    I tried to use mvnDebug clean install. But this threw me an error saying command not found

  • Boris the Spider
    Boris the Spider over 10 years
    See here for the correct command line options to use. XDebug is very slow.