Summary of three ways to deploy projects in Tomcat

The first way: the project is placed directly in the /webapps directory

1. Put the written and compiled web project into /webapps, or put the project into a war package, it will be automatically decompressed after tomcat is started

2. Restart tomcat

The second way: modify the /conf/server.xml file

1. Open the /conf/server.xml file under tomcat and enter the project configuration information between the <Host> </Host> tags

<Context path="/WebProject" docBase="D:/WebProject" reloadable="true" />

        path: the path name when the browser accesses
        docBase: the path where the WebRoot of the web project is located, note that it is the path of the WebRoot, not the path of the project. In fact, it is the compiled project

        Reloadable: Set whether tomcat reloads the project when the project is changed

2. Restart tomcat

The third way: add configuration under tomcat\conf\Catalina\localhost

1. Go to the tomcat\conf\Catalina\localhost directory and create a new project name.xml file

2. In the newly created xml file, add the following configuration statement (same as above, but no path configuration is required, and the addition will also be ignored, because the file name is equivalent to the above path)

<Context docBase="D:/WebProject" reloadable="true" />

3. Restart tomcat

Summarize:

①. The first method is relatively common, but we need to copy the compiled project to the webapps directory again, and there are two more steps.

2. The second method is configured directly in the server.xml file, but since the tomcat5.0 version, the server.xml file is used as the main configuration file for tomcat startup. Once tomcat is started, this file will not be read again. Therefore, the web project cannot be published after the tomcat service is started

3. The third method is the best, each project is configured separately, tomcat will use the file name of the xml file in the \conf\Catalina\localhost directory as the context path of the web application, regardless of the configuration in <Context> The path path, so when configuring, you can omit the path.

It is usually more convenient to use the third method

 

 

Guess you like

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