Tomcat configuration in Eclipse

2019-03-20 02:14发布

I'm using Eclipse Luna with Tomcat 8 and am confused by the different locations of config files.

I've installed Tomcat on my local machine and configured Tomcat in Eclipse as follows:

enter image description here

So there are 4 directories involved

  • 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)

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?

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"?

2条回答
Summer. ? 凉城
2楼-- · 2019-03-20 02:26

Configuration files are stored in your workspace under a dedicated project (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 base (b) is a base path for work folders (temp and work) and also for deployed applications.

And the path for deployed applications (d) is just a name of the directory within catalina base where your applications are being deployed.


where do I configure my server for a specific application that I start from within Eclipse during development?

You don't configure it in any file, but rather within Eclipse. Your application needs to be configured as a Dynamic Web Project to enable server deployment.

查看更多
唯我独甜
3楼-- · 2019-03-20 02:41

Your configuration for the server that you start from Eclipse IDE are as you have given during the Server Location settings, in your case:

/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)


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.

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:\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.

And with configuration in the subfolder /Servers/Tomcat v8.0 Server at localhost-config in above path.

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.

Read more at Eclipse Luna - Configuration of the Eclipse Workspace And you can always check the startup arguments to understand it better how everything is connected, see image below:

enter image description here

查看更多
登录 后发表回答