Common configuration when using Tomcat Plugin to start Tomcat in Eclipse

This article is mainly used to record the common configuration and function of starting tomcat through the plug-in in the perspective view (that is, the three kittens in the toolbar) after installing the Tomcat plug-in.

1. Of course, the tomcat plug-in and tomcat must be installed. I won't say much here. There are a bunch of them.

Second, the configuration of tomcat in Eclipse: Window>Preferences>Tomcat   see the figure below


Figure 1 is the installation path of tomcat.

Figure 2 is an option of Context declaration mode, which is mainly used to configure the startup path of your project in tomcat.

    The first Server.xml is to configure your project path to the server.xml file of tomcat (strongly not recommended);

    The second Context files is to configure your project path into a separate configuration file. The storage location of this configuration file is the Contexts irectory below. At the same time, the name of this configuration file will be the same as your access path name (note that it is not a project name).

Figure 3 is the version of Tomcat you want to use. The one I use is a bit old, and I just mean it.

3. The third step is to configure the properties in the project: right-click the project > tomcat, see the figure below


1 in the figure is used to associate the project and tomcat, just do it first.

2 Context name in the figure is used to configure the access path name of your project. For example, mine is /web, then after I start tomcat and enter http://localhost:8080/web in the browser, I will access mine Project, the configuration file of the access path of the project mentioned on the previous page also contains the configuration of this path, and the name of the configuration file must be the same as this name, for example, the name of my configuration file is web.xml where path=" /web" This property is the access path of the project.

Figure 3 is the root directory of your project, which is the upper-level directory of WEB_INF, tomcat will follow this directory to find your web.xml file ( this web.xml and the previous web.xml are not the same thing ), mine is content, this is the name given when eclipse creates a new project, the default in eclipse is WebContent, and the default in myeclipse is WebRoot, I found this Subdirectory to set as web application root (optional) in eclipse 4.7 I can't save it after modification. Other versions don't have this problem, and I haven't found a specific solution. If anyone knows, please tell me in the message area, I'd be grateful. If a small partner also encounters this problem, my temporary solution is to put the configuration file in tomcat, that is, my web.xml, in the directory tomcathome\conf\Catalina\localhost\web.xml with docBase="D:\ workspace\web\ content " If you add that content manually, you can also temporarily deal with it.

Figure 4 is to update the configuration file, that is, when you modify the page, eclipse will automatically update the configuration file, which is the file tomcathome\conf\Catalina\localhost\web.xml.

After selecting 5 in the figure, you do not need to restart tomcat after modifying the java file and recompiling, tomcat will automatically reload the class file.

After 6 is selected in the figure, the context log will be printed in the eclipse console.

Fourth, the configuration file generated after completing the above configuration is as follows:

<Context path="/web" reloadable="true" docBase="D:\workspace\web\content" workDir="D:\workspace\web\work" >
    <Logger className="org.apache.catalina.logger.SystemOutLogger" verbosity="4" timestamp="true"/>
</Context>

Then click on the first kitten in eclipse, and enter the access address in your browser to open your page.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326003521&siteId=291194637