设置 maven+jetty+eclipse 的调试配置

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7875002/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 20:37:06  来源:igfitidea点击:

Setting debug configuration for maven+jetty+eclipse

eclipsedebuggingmavenmaven-jetty-plugin

提问by azhar_salati

I have created a web app using maven in eclipse. I am using jetty for running the app. I am able to run the app using the maven jetty plugin. But I am facing difficulty while debugging the app - The steps that i have followed to setup debug settings are from the below link http://www.clickonchris.com/2010/05/configuring-jetty-maven-and-eclipse-together-with-hot-deploy/

我在 Eclipse 中使用 Maven 创建了一个 Web 应用程序。我正在使用 jetty 来运行该应用程序。我可以使用 maven jetty 插件运行该应用程序。但是我在调​​试应用程序时遇到了困难 - 我设置调试设置所遵循的步骤来自以下链接 http://www.clickonchris.com/2010/05/configuring-jetty-maven-and-eclipse-together -带热部署/

I can run the app at port 8080 and it keeps on Listening for transport dt_socket at address: 4000. For debugging i have given port 4000. But when i start the debugger in eclipse it gives me a window with following error - "Failed to connect to remote VM. Connection refused. Connection refused: connect" Can some one help me out in resolving this issue for debugging the app.

我可以在端口 8080 上运行应用程序,它会继续在地址 4000 处监听传输 dt_socket。为了调试,我给了端口 4000。但是当我在 Eclipse 中启动调试器时,它给了我一个窗口,并显示以下错误 - “无法连接到远程虚拟机。连接被拒绝。连接被拒绝:连接“有人可以帮助我解决这个问题以调试应用程序。

Thanks!!!

谢谢!!!

回答by Kapil Raju

Set MAVEN_OPTS using -

使用 - 设置 MAVEN_OPTS

export MAVEN_OPTS="-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n"

Then start jetty using -

然后使用 - 启动码头

mvn jetty:run

Start remote debugging from your fav IDE on port 8000

在端口 8000 上从您喜欢的 IDE 开始远程调试

回答by Antti Kolehmainen

Here's a quick workaround. I was battling with this problem also and after a while I achieved a lazy solution.

这是一个快速的解决方法。我也在与这个问题作斗争,一段时间后我找到了一个懒惰的解决方案。

I use Eclipse Indigo with m2eclipse. I created a new Run Configuration: Right-Clicked the project in Project Explorer -> Run As... -> maven build. Then I defined the necessary maven commands/goals to run the project with jetty straight from Eclipse.

我将 Eclipse Indigo 与 m2eclipse 一起使用。我创建了一个新的运行配置:在 Project Explorer 中右键单击该项目 -> Run As... -> maven build。然后我定义了必要的 maven 命令/目标,以直接从 Eclipse 运行带有 jetty 的项目。

Finally I just ran the newly created configuration in Debug mode and got debug working. This probably messes up something else(?) but works as a quick workaround.

最后我只是在调试模式下运行新创建的配置并让调试工作。这可能会搞砸其他事情(?),但可以作为一种快速解决方法。

回答by Vishal Goyal

As suggested by h3xstream in one of the comments, you can run using mvnDebug jetty:run.

正如 h3xstream 在其中一条评论中所建议的,您可以使用mvnDebug jetty:run.

回答by aribeiro

As mentioned by Pascal Thivent in thisanswer, since Maven 2.0.8one can use mvnDebugin the following way:

正如 Pascal Thivent 在这个答案中提到的,由于Maven 2.0.8可以通过mvnDebug以下方式使用:

mvnDebug jetty:run

This will start maven in debugger mode on port 8000.

这将在端口 8000 上以调试器模式启动 maven。