Eclipse 在哪里使用 WTP 部署 Web 应用程序?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2119351/
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 19:08:44  来源:igfitidea点击:

Where does Eclipse deploy web applications using WTP?

eclipsetomcateclipse-wtp

提问by Thunderhashy

I have a web application (WAR file). When I deploy it through Eclipse 3.5 using the WTP tools, I am able to start the Tomcat server from within Eclipse and view all the pages of the application. However I don't see my WAR file inside the webappsfolder of Tomcat home directory (or for that matter its exploded format). I was under the impression that Tomcat reads all web applications under its webappsfolder. How does Tomcat read my application in this case? I am using Tomcat 5.5.17 as my application server.

我有一个 Web 应用程序(WAR 文件)。当我使用 WTP 工具通过 Eclipse 3.5 部署它时,我能够从 Eclipse 内启动 Tomcat 服务器并查看应用程序的所有页面。但是,我在 Tomcat 主目录的webapps文件夹中没有看到我的 WAR 文件(或者就此而言它的分解格式)。我的印象是 Tomcat 会读取其webapps文件夹下的所有 Web 应用程序。在这种情况下,Tomcat 如何读取我的应用程序?我使用 Tomcat 5.5.17 作为我的应用程序服务器。

采纳答案by BalusC

It's just all definied in the context.xmlwhich Eclipse has given to Tomcat. If you want to configure this behaviour, then doubleclick the Tomcat instance in the servers view and check the Server locationssection. To achieve what you initially want/expected, you need to select Use Tomcat installationand if necessary also specify the Deploy path.

这一切都在context.xmlEclipse 给 Tomcat 的定义中定义。如果要配置此行为,请双击服务器视图中的 Tomcat 实例并检查服务器位置部分。要实现您最初想要/预期的内容,您需要选择使用 Tomcat 安装,并在必要时指定Deploy path

回答by hshib

I recently have to figure out more detail on this topic to troubleshoot application startup issues so I note it here.

我最近必须找出有关此主题的更多详细信息以解决应用程序启动问题,因此我将其记录在此。

Where is the application deployed?

应用程序部署在哪里?

It is determined by the server configuration. Double click on the server in the servers view to look at the server "Overview". In the "Server Locations" section, there are default value configured:

它由服务器配置决定。在服务器视图中双击服务器以查看服务器“概览”。在“服务器位置”部分,配置了默认值:

  • Server Path: .metadata/.plugins/org.eclipse.wst.server.core/tmp0
  • Deploy Path: wtpwebapps
  • 服务器路径: .metadata/.plugins/org.eclipse.wst.server.core/tmp0
  • 部署路径: wtpwebapps

Also the application "module" is defined in the "Modules" tab of the server configuration which specify the application path, document base and the module name. For example, you deploy your project myappto the path /MyApp.

此外,在服务器配置的“模块”选项卡中定义了应用程序“模块”,它指定了应用程序路径、文档库和模块名称。例如,您将项目部署myapp到路径/MyApp.

So if your workspace is /home/me/workspace/myapp, the path to your application deployment directory is:

因此,如果您的工作区是/home/me/workspace/myapp,则应用程序部署目录的路径是:

/home/me/workspace/myapp/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/myapp. 

What application files are deployed?

部署了哪些应用程序文件?

The contents of deployment is determined by "Deployment Assembly" in the project properties. Each entry in the assembly defines what files are deployed to what path. Example:

部署的内容由项目属性中的“部署程序集”决定。程序集中的每个条目都定义了将哪些文件部署到哪些路径。例子:

  • /src/main/java -> WEB-INF/classes
  • /src/main/resources -> WEB-INF/classes
  • /src/main/webapp -> /
  • Maven Dependencies -> WEB-INF/lib
  • /src/main/java -> WEB-INF/classes
  • /src/main/resources -> WEB-INF/classes
  • /src/main/webapp -> /
  • Maven Dependencies -> WEB-INF/lib

So if you have the file src/main/webapp/WEB-INF/web.xmlin your source tree, it will be deployed to:

因此,如果您src/main/webapp/WEB-INF/web.xml的源代码树中有该文件,它将被部署到:

/home/me/workspace/myapp/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/myapp/WEB-INF/web.xml