Eclipse 中的 Tomcat 配置
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/30094103/
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
Tomcat configuration in Eclipse
提问by Raphael Roth
I'm using Eclipse Luna with Tomcat 8 and am confused by the different locations of config files.
我正在将 Eclipse Luna 与 Tomcat 8 一起使用,并且对配置文件的不同位置感到困惑。
I've installed Tomcat on my local machine and configured Tomcat in Eclipse as follows:
我已经在我的本地机器上安装了 Tomcat 并在 Eclipse 中配置了 Tomcat,如下所示:
So there are 4 directories involved
所以有4个目录涉及
a) catalina home: C:\Program Files\AppServers\Tomcat8
b) catalina base: C:\Users\xxx\projectname\Tomcat
c) the configuration-path within my Eclipse workspace: /Servers/Tomcat v8.0 Server at localhost-config
d) Deploy path: wtpwebapps which is a subdirectory of a)
a) catalina 主目录:C:\Program Files\AppServers\Tomcat8
b) catalina 基础:C:\Users\xxx\projectname\Tomcat
c) 我的 Eclipse 工作区中的配置路径:/Servers/Tomcat v8.0 Server at localhost-config
d) 部署路径:wtpwebapps 是 a) 的子目录
Both in a,b,c I have the same set of config-files (catalina.properties, context.xml, server.xml...). What is the hierarchy of these files, where do I configure my server for a specific application that I start from within Eclipse during development?
在 a、b、c 中,我都有相同的配置文件集(catalina.properties、context.xml、server.xml...)。这些文件的层次结构是什么?在开发过程中,我应该在哪里为我在 Eclipse 中启动的特定应用程序配置我的服务器?
Edit: Related to this: What is happening if I right-click on the server in the servers-tab and choose "clean Tomcat working directory" or simply "clean"?
编辑:与此相关:如果我右键单击服务器选项卡中的服务器并选择“清理 Tomcat 工作目录”或简单地“清理”会发生什么?
回答by MrSimpleMind
Your configuration for the server that you start from Eclipse IDE are as you have given during the Server Location
settings, in your case:
您从 Eclipse IDE 启动的服务器的配置与您在Server Location
设置期间给出的一样,在您的情况下:
/Servers/Tomcat v8.0 Server at localhost-config
/Servers/Tomcat v8.0 Server at localhost-config
(This is configured in Eclipse, no need to modify them manually. But you can check the files if you want to make the same settings in "production" etc)
(这是在Eclipse中配置的,不需要手动修改。但如果你想在“生产”等中进行相同的设置,你可以检查文件)
Now to the details...
现在详细...
About the hierarchy! As you already know, I hope, Catalina is the engine in tomcat which implements the Servlet/JSP parts.
关于等级!如您所知,我希望 Catalina 是 tomcat 中实现 Servlet/JSP 部分的引擎。
C:\Program Files\AppServers\Tomcat8
here is your Tomcat8 binaries, where you have installed tomcat. It can run as stand-alone without Eclipse, but depends on the configuration you might not see the same apps as you deploy from Eclipse. This depends on your configuration in Eclipse.
C:\Program Files\AppServers\Tomcat8
这是您的 Tomcat8 二进制文件,您已在其中安装了 tomcat。它可以在没有 Eclipse 的情况下独立运行,但取决于配置,您可能看不到与从 Eclipse 部署的应用程序相同的应用程序。这取决于您在 Eclipse 中的配置。
C:\Users\xxx\projectname\Tomcat
is your Tomcat custom folder, where you use in Eclipse. This you have chosen to make base and eclipse project separate. Maybe you dont want to touch the Tomcat8 installation. Here exists the needed files that Eclipse put to be able run a tomcat instance.
C:\Users\xxx\projectname\Tomcat
是您在 Eclipse 中使用的 Tomcat 自定义文件夹。您已选择将 base 和 eclipse 项目分开。也许你不想碰Tomcat8的安装。这里存在 Eclipse 用来运行 tomcat 实例所需的文件。
And with configuration in the subfolder /Servers/Tomcat v8.0 Server at localhost-config
in above path.
并/Servers/Tomcat v8.0 Server at localhost-config
在上述路径的子文件夹中进行配置。
When Eclipse run tomcat it uses the binaries (from C:\Program Files\AppServers\Tomcat8
) with arguments for setting your base (i.e. C:\Users\xxx\projectname\Tomcat
) and with the application folder (wtpwebapps
) for deployments.
当 Eclipse 运行 tomcat 时,它使用二进制文件 (from C:\Program Files\AppServers\Tomcat8
) 和参数来设置基础 (即C:\Users\xxx\projectname\Tomcat
) 和应用程序文件夹 ( wtpwebapps
) 用于部署。
Read more at Eclipse Luna - Configuration of the Eclipse WorkspaceAnd you can always check the startup arguments to understand it better how everything is connected, see image below:
在Eclipse Luna - Eclipse 工作区的配置中阅读更多内容 您可以随时检查启动参数以更好地了解一切是如何连接的,请参见下图:
回答by Pavel Horal
Configuration files are stored in your workspace under a dedicated project (c).
配置文件存储在您的工作区中的专用项目 ( c) 下。
Original path catalina home(a) is the path where Tomcat libraries are. Configuration is not being read from there... this allows a different configuration for the Tomcat when it is being run by Eclipse.
原始路径catalina home( a) 是 Tomcat 库所在的路径。没有从那里读取配置...这允许 Tomcat 在 Eclipse 运行时使用不同的配置。
Catalina base(b) is a base path for work folders (tempand work) and also for deployed applications.
Catalina base( b) 是工作文件夹(temp和work)以及已部署应用程序的基本路径。
And the path for deployed applications (d) is just a name of the directory within catalina basewhere your applications are being deployed.
部署应用程序的路径 ( d) 只是catalina base中部署应用程序的目录的名称。
where do I configure my server for a specific application that I start from within Eclipse during development?
在开发过程中,我应该在哪里为我从 Eclipse 中启动的特定应用程序配置我的服务器?
You don't configure it in any file, but rather within Eclipse. Your application needs to be configured as a Dynamic Web Projectto enable server deployment.
您不在任何文件中配置它,而是在 Eclipse 中配置它。您的应用程序需要配置为动态 Web 项目才能启用服务器部署。