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

查看:130
本文介绍了在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天全站免登陆