调试部署在tomcat中的java应用程序
我有一个部署在 tomcat 中的应用程序。后来我在Eclipse中将代码配置为项目。我想通过 eclipse 连接到 tomcat 并调试应用程序。 尝试设置远程调试连接会引发错误。我需要在 tomcat 中的某处添加任何条目吗?
I have an application that I deployed in tomcat. Later I configured the code as a project in Eclipse. I want to connect to the tomcat via eclipse and debug the application.
Trying to setup a remote debug connection is throwing up errors. Is there any entry that I need to add somewhere in tomcat?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(8)
首先,您需要以调试模式运行 Tomcat。最简单的方法是修改启动文件(.bat 或 .sh,具体取决于您是否使用 Windows)。找到包含
start
命令的文件附近或末尾的行,并将其更改为jpda start
。这将导致 Tomcat 以调试模式启动,侦听端口8000
。接下来,要通过 Eclipse 连接到此进程,请选择“运行”菜单并选择“调试配置...”。在左侧窗格中,选择
远程 Java 应用程序
,然后单击列表上方的新启动配置
按钮。需要注意的重要设置是Host
和Port
字段。主机值必须与 Tomcat 进程的主机名匹配,端口应为 8000。您可能还需要在Source
选项卡上添加条目,以确保所有源代码都可供单步执行。First, you need to run Tomcat in debugging mode. The easiest way to do that is to modify the startup file (.bat or .sh depending if you are Windows or not). Find the line near or at the end of the file that contains the
start
command, and change it tojpda start
. This will cause Tomcat to start in debugging mode listening on port8000
.Next, to connect to this process via Eclipse, select the
Run
menu and chooseDebug Configurations...
. In the pane on the left, chooseRemote Java Application
and click theNew launch configuration
button above the list. The important settings to note are theHost
andPort
fields. The host value must match the hostname of the Tomcat process, and the port should be8000
. You also might need to add entries on theSource
tab to ensure that all of the source code is available to step through.出口战到 tomcat 服务器
war 文件可用 此处。
Export war to tomcat server
The war file is available here.
只需将
startup.bat
中的行(如果您使用的是 Windows)从:
更改为:
Simply change the line in
startup.bat
(if you are using Windows)from:
to:
是的,您需要配置tomcat以接受远程调试连接。有一个关于如何使用各种 IDE 进行此操作的常见问题解答。
https://cwiki.apache.org/confluence/display/TOMCAT/开发#开发-Q1
yes, you need to configure tomcat to accept remote debugging connections. There is a FAQ on how to do it with various IDEs.
https://cwiki.apache.org/confluence/display/TOMCAT/Developing#Developing-Q1
然后双击左侧菜单列表中的“远程 Java 应用程序”。浏览您想要添加的项目,然后单击“应用”。
Then Double click on the Remote Java Application from left menu list. browse for the project u wanna add in then click apply.
调试对我有用。我使用的是 tomcat 8,在 centos 7 上配置。更改 2 个设置后,调试端口为我打开。
重新启动 tomcat。
在 eclipse 中,转到运行 tomcat 的运行>调试配置>远程 java 应用程序>添加主机 ip 和端口(8000)。
就我而言,我也需要通过防火墙打开 8000。
Debug worked for me. I was using tomcat 8, configured on centos 7. Debug port opened for me after changing 2 settings.
Restart the tomcat.
In eclipse go to Run>Debug configuration>Remote java application>Add host ip and port(8000) where tomcat is running.
In my case i required to open 8000 through firewall too.
使用 eclipse 设置 tomcat 调试器的步骤
安装以下内容:
Steps to setup the tomcat Debugger with eclipse
Install the following things:
除了远程调试之外,如果您在 eclipse 中添加了 tomcat,您还可以在 eclipse 中本地调试您的应用程序。
只需启动服务器并右键单击您的应用程序,然后从调试菜单中单击服务器上的调试。
如果您有多模块 Maven 项目,请在刚刚显示的服务器上调试带有 war 打包的模块。
如果你想调试一个在启动时自行运行的类,比如用 @PostConstruct 注释的方法,请记住你应该增加服务器超时。
为此,请转到服务器视图并双击 tomcat,然后在服务器预览选项卡中增加超时值。
Beside remote debugging, you can debug your app locally within eclipse if you added tomcat in eclipse.
just start server and wright click your app and from debug menu hit debug on server.
If you have multi module maven project, debug on server just shown up for module with war packaging.
If you want debug a class that runs at startup by self, like methods that annotated with @PostConstruct, remember that you should increase server timeout.
To do that, go to server view and double click on tomcat and in server preview tab, increase the timeout value.