如何从maven命令行远程调试java应用程序

时间:2014-02-10 19:59:44

标签: java maven tomcat remote-debugging

我有一个在IntelliJ中运行的java应用程序。我可以知道如何从maven命令行远程调试应用程序。

我尝试使用mvnDebug clean install。但这给我一个错误,说找不到命令

1 个答案:

答案 0 :(得分:6)

您可以使用远程调试:

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"

然后在你的eclipse中,你可以使用远程调试并将调试器附加到localhost:1044。 或者配置目标来调试配置,创建" Maven build" debug config:

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

或针对特定的TestSuite:

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

创建额外的"远程Java应用程序"配置:

  

Host = localhost Port = 5005

您可以在此处找到更多文档: http://maven.apache.org/surefire/maven-surefire-plugin/examples/debugging.html