gpt4 book ai didi

java - 使用 m2eclipse 开发 Web 应用程序的首选方式

转载 作者:搜寻专家 更新时间:2023-10-31 19:31:36 25 4
gpt4 key购买 nike

在开发 Maven web 应用程序时,我通常使用 jetty-maven-plugin 来快速启动我的应用程序以进行本地测试和调试。使用 m2eclipse 启动有一个缺点,即没有正确包含所有调试源,即使它们是由 Maven 下载的(参见 Source lookup does not seem to work)。

在 Eclipse 中调试 Maven Web 应用程序的首选方法是什么?我特别喜欢与 gwt-maven-plugin 配合使用的配置。

最佳答案

我使用 m2eclipse 开发 Web 应用程序的首选方法是……不使用它。相反,我使用 Debugging with the Maven Jetty Plugin in Eclipse 中描述的方法我在下面引用:

Step 1

Go to the Run/External Tools/External Tools ..." menu item on the "Run" menu bar. Select "Program" and click the "New" button. On the "Main" tab, fill in the "Location:" as the full path to your "mvn" executable. For the "Working Directory:" select the workspace that matches your webapp. For "Arguments:" add jetty:run.

Move to the "Environment" tab and click the "New" button to add a new variable named MAVEN_OPTS with the value:

-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=4000,server=y,suspend=y

If you supply suspend=n instead of suspend=y you can start immediately without running the debugger and launch the debugger at anytime you really wish to debug.

Step 2

Then, pull up the "Run/Debug/Debug ..." menu item and select "Remote Java Application" and click the "New" button. Fill in the dialog by selecting your webapp project for the "Project:" field, and ensure you are using the same port number as you specified in the address= property above.

Now all you need to do is to Run/External Tools and select the name of the maven tool setup you created in step 1 to start the plugin and then Run/Debug and select the name of the debug setup you setup in step2.

From instructions provided by Rolf Strijdhorst on the Maven mailing list

Stopping Jetty

In order to stop the jetty server the "Allow termination of remote VM" should be checked in debug dialog in Step 2. When you have the jetty server running and the debugger connected you can switch to the debug perspective. In the debug view, right click on the Java HotSpot(TM) Client VM[localhost:4000] and chose terminate. This will stop the debugger and the jetty server.

关于java - 使用 m2eclipse 开发 Web 应用程序的首选方式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1536445/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com