使用Eclipse和Maven打包为WAR的Java Web应用程序的最佳方法? [英] Best way to debug Java web application packaged as a WAR using Eclipse and Maven?
问题描述
我之前没有构建Java Web应用程序,但是我已经完成了足够的测试,Maven正在构建我的WAR文件。它是一个多模块的Maven项目,依赖模块在WAR的WEB-INF / lib目录中都有他们的JAR文件。
I've not built a Java web application before, but I have it complete enough to test and Maven is building my WAR file just fine. It is a multi-module Maven project and the dependent modules all have their JAR files in the WEB-INF/lib directory of the WAR.
所以一切似乎都很好,但是如何调试?我知道如何(从命令行)在我的机器上的Tomcat中运行WAR。我也认为我也知道如何从命令行设置和运行Maven Jetty插件。但是如何最好地调试...使用Eclipse中的所有断点和变量检查?
So everything seems fine, but how to debug? I know how to (from the command line) run the WAR in Tomcat on my machine. I also think I know how to set up and run the Maven Jetty plugin from the command line as well. But how best to debug...with all the break points and variable inspection I love with Eclipse?
是否有某种启动配置,我应该创建,还是远程附加调试器?在Eclipse中有什么可以帮助...像插件吗?
Is there some kind of launch configuration I should create, or do I attach the debugger remotely? Is there something in Eclipse that can help...like a plugin?
推荐答案
如果你运行你的WAR与tomcat / jetty插件通过调试选项到Maven:
If you run your WAR with tomcat/jetty plugin pass debug options to the Maven:
export MAVEN_OPTS="-Xnoagent -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000" mvn tomcat:run
如果您使用常规Tomcat运行WAR,只需运行它即可启用JPDA(调试器)支持:
If you run your WAR using the regular Tomcat, just run it with JPDA (debugger) support enabled:
$TOMCAT_HOME/bin/catalina.sh jpda start
Tomcat的默认端口6 JPDA为8000。
Default port for Tomcat 6 JPDA is 8000.
现在,将Eclipse(调试 - >远程Java应用程序)连接到端口8000和享受您的精细调试会话。
Now connect with the Eclipse (Debug -> Remote Java Application) to the port 8000 and enjoy your fine debugging session.
这篇关于使用Eclipse和Maven打包为WAR的Java Web应用程序的最佳方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!