在 Maven 中调试? [英] Debugging in Maven?

查看:16
本文介绍了在 Maven 中调试?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以从 Maven 启动调试器,例如 jdb?我有一个成功编译项目的 pom.xml 文件.但是,该程序挂在某处,我真的很想启动 jdb 或等效的调试器来查看发生了什么.

Is it possible to launch a debugger such as jdb from Maven? I have a pom.xml file that compiles the project successfully. However, the program hangs somewhere and I would really like to launch jdb or an equivalent debugger to see what's happening.

我使用 mvn compile 编译并使用:

I compile using mvn compile and launch using:

mvn exec:java -Dexec.mainClass="com.mycompany.app.App"

我期待的是:

mvn exec:jdb -Dexec.mainClass="com.mycompany.app.App"

启动调试器,但像往常一样,我的期望与 maven 的理念不一致.

to launch the debugger but, as usual, my expectations are incongruent with maven's philosophy.

此外,我找不到任何文档(在 Maven 的网站或谷歌上)来描述调试是如何工作的.我怀疑我必须使用一些插件.

Also, I couldn't find any documentation (on Maven's website or google) to describe how debugging works. I suspect that I have to use some plugin.

推荐答案

正如Brian所说,可以使用远程调试:

Just as Brian said, 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"

然后在您的 eclipse 中,您可以使用远程调试并将调试器附加到 localhost:1044.

Then in your eclipse, you can use remote debugging and attach the debugger to localhost:1044.

这篇关于在 Maven 中调试?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆