如何在Eclipse中正确管理Tomcat Web应用程序? [英] How to properly manage Tomcat web apps inside Eclipse?

查看:127
本文介绍了如何在Eclipse中正确管理Tomcat Web应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我曾经在我的机器上单独运行Tomcat。我有一个Ant脚本可以重建我的项目,在本地部署它,然后重启Tomcat。这一切都运行正常,但我无法在Eclipse中调试Web应用程序。

I used to run Tomcat separately on my machine. I had an Ant script that would rebuild my project, deploy it locally, and restart Tomcat. That all worked ok, but I wasn't able to debug the web app inside Eclipse.

所以我学会了如何在Eclipse中设置Tomcat并让我的web应用程序运行。现在问题是我不完全理解如何以这种方式管理它。 Eclipse设置为根据更改自动构建我的项目,但这些更改似乎并不总是反映在Web应用程序中。有时我必须手动构建项目并手动清理服务器以反映更改。

So I learned how to setup Tomcat inside Eclipse and got my web app running. Now the problem is that I don't understand fully how to manage it this way. Eclipse is set to automatically build my project on changes, but those changes don't seem to always be reflected in the web app. Sometimes I have to manually build the project and manually "clean" the server for the changes to be reflected.

是否有关于如何管理此设置的规则?例如,如果我只更改JSP,那么它会自动同步吗?如果我更改了servlet类,那么我需要手动重建项目吗?这些规则是否一致,或者我应该每次只手动重建和清理?

Are there rules somewhere about how to manage this setup? For instance, if I only change a JSP then will it automatically be synchronized? If I change a servlet class, then I need to manually rebuild the project? Are these rules consistent, or should I just manually rebuild and clean every time?

如果有人能给我最佳实践规则或指向我,我真的很感激学习如何管理这种环境的良好资源。

I would really appreciate it if someone could give me the best practice rules or point me to a good resource to learn how to manage this environment.

PS。我正在使用Eclipse 3.4.1 Java EE包和Tomcat v5.5

PS. I am using Eclipse 3.4.1 Java EE package and Tomcat v5.5

推荐答案

你可以像你一样使用Eclipse和Tomcat提到。首先是如何设置的基础知识:

You can use Eclipse and Tomcat in the way you mention. First the basics of how to set it up:


  1. 在Servers视图中设置一个指向TOMCAT_HOME的新Tomcat服务器

  2. 确保您的项目是EclipseWeb项目。您可能需要创建一个虚拟的并复制.settings中的一些文件(查看wst文件)。

  3. 通过右键单击Servers视图中的服务器和Add and Remove Projects ...将项目部署到Tomcat,将项目添加到服务器。

您可以运行服务器并测试它,就像在Eclipse之外运行Tomcat一样。如果您在调试模式下运行服务器,您可以设置断点并逐步执行代码。

You can run your server and test it out just like you were running Tomcat outside of Eclipse. If you run the server in Debug mode you can set breakpoints and step through the code.

至于何时需要重新启动服务器Eclipse通常非常适合自动运行 - 部署更改。您几乎不需要重新启动以更改jsp页面。如果更改类,如果更改方法的主体,它将自动部署更改(通常)。如果更改类的签名(添加或删除方法或更改方法),您几乎总是需要重新启动。对配置文件(web.xml或类似文件)的任何更改也几乎总是需要重新启动。

As for when you will need to restart the server Eclipse is usually pretty good about auto-deploying the changes. You will pretty much never need to restart for changes to jsp pages. If you change a class it will auto-deploy the change (usually) if you change the body of a method. If you change the signature of a class (add or remove a method or change args for it) you will almost always need to restart. Any changes to configuration files (web.xml or similar) will also almost always require a restart.

要重新启动,只需单击服务器视图中的调试或运行按钮。所有更改都将重新部署到Tomcat中。

To restart just click on the "Debug" or "Run" button in the Server view. All your changes will be redeployed into Tomcat.

需要注意的一点是,在默认配置中,不会使用TOMCAT_HOME中的webapp目录。相反,它将使用Eclipse工作区目录下的文件夹(WORKSPACE / .metadata / .plugins / org.eclipse.wst.server.core / tmp0)。

One thing to watch out for is that in the default configuration your "webapp" directory in TOMCAT_HOME will not be used. Instead it will use a folder under your Eclipse workspace directory (WORKSPACE/.metadata/.plugins/org.eclipse.wst.server.core/tmp0).

这篇关于如何在Eclipse中正确管理Tomcat Web应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆