【问题标题】:How to remote debug java application from maven command line如何从 Maven 命令行远程调试 Java 应用程序
【发布时间】:2014-03-08 08:20:02
【问题描述】:

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

我尝试使用 mvnDebug 全新安装。但这给我一个错误,说找不到命令

【问题讨论】:

  • 不确定是否理解问题。如果您的应用程序在 IntelliJ 中运行,为什么要使用 Maven 命令进行远程调试?
  • 我的一个测试用例在 IntelliJ 中运行失败,但是当我运行 mvn clean test 时它们失败了。这就是为什么我想从命令行进行远程调试
  • @RakeshGourineni:很难理解你想要达到的目标。请编辑问题并重新措辞,使其包含您问题中的信息。
  • @Rakesh,如果它与万无一失相关,请看这里:maven.apache.org/surefire/maven-surefire-plugin/examples/…

标签: java maven tomcat remote-debugging


【解决方案1】:

可以使用远程调试:

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”调试配置:

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

或针对特定的测试套件:

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

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

主机 = 本地主机端口 = 5005

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

【讨论】:

  • 请参阅here,了解要使用的正确命令行选项。 XDebug 很慢。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2010-09-10
  • 1970-01-01
  • 2010-11-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多