Tomcat deployment Method

Source: Internet
Author: User

 

I. Static deployment

 

1. Directly copy the web project file to the webapps directory.

The Webapps directory of Tomcat is the default application directory of Tomcat. When the server starts, all applications under this directory will be loaded. Therefore, you can package the JSP program into a war package and place it in the directory. The server will automatically unbind the war package and generate a folder with the same name under this directory. A war package is a jar package with a special format. It compresses all the content of a web program. You can use many development tools such as Eclipse in the IDE environment for packaging. You can also run the cmd command: jar-cvf mywar. war myweb

The default application directory webapps can also be changed. Open the server. xml file in the conf directory of Tomcat and find the following content:

 

<Host name = "localhost" appBase = "webapps"

 

UnpackWARs = "true" autoDeploy = "true"

 

XmlValidation = "false" xmlNamespaceAware = "false">

 

Modify the appBase.

2. Specify

In the Tomcat configuration file, a Web application is a specific Context. You can deploy a JSP application in the new Context in server. xml. Open the server. xml file and create a Context in the Host tag. The content is as follows.

 

 

In the conf directory of tomcat, add the following to the

<Context path = "/hello" docBase = "D:/workspace/hello/WebRoot" debug = "0" privileged = "true">

</Context>

 

Or

 

<Context path = "/myapp" reloadable = "true" docBase = "D:/myapp" workDir = "D:/myapp/work"/>

 

Or

 

<Context path = "/sms4" docBase = "D:/workspace/sms4/WebRoot"/>

 

 

Note:

 

Path is a virtual path;

 

DocBase is the physical path of the application;

 

WorkDir is the working directory of the application. It stores the files generated during the running process related to the application;

 

 

 

Debug sets the debug level. 0 indicates that the minimum information is provided, and 9 indicates that the maximum information is provided.

 

When privileged is set to true, Tomcat Web applications are allowed to use the Servlet in the container.

 

If reloadable is true, tomcat will automatically detect changes to the application's/WEB-INF/lib and/WEB-INF/classes directories, automatically load new applications, you can change the application without restarting tomcat to achieve hot deployment.

 

Hot deployment of antiResourceLocking and antiJARLocking is a parameter that needs to be configured. The default value "false" avoids updating a webapp. Sometimes Tomcat cannot completely delete the old webapp, usually a jar package under the WEB-INF/lib is left behind and Tomcat must be closed to be deleted, which leads to automatic deployment failure. Set to true. Tomcat copies the corresponding source files and jar files to a temporary directory when running the corresponding webapp.

3. Create a Context File

In the conf directory, create a new Catalina \ localhost directory and create an xml file in the directory. The name cannot be obtained at will. It must be the same as the name after path, according to the following path configuration, the xml name should be hello (hello. xml), the content of the xml file is:

 

<Context path = "/hello" docBase = "E:/workspace/hello/WebRoot" debug = "0" privileged = "true"> </Context>

 

 

 

The example of tomcat is as follows:

 

<Context docBase = "$ {catalina. home}/server/webapps/host-manager"

 

Privileged = "true" antiResourceLocking = "false" antiJARLocking = "false">

 

</Context>

 

This example is provided by tomcat. The edited content is actually the same as the second method. The xml file name is the access path, which can hide the real name of the application.

 

4. Note:

 

When deleting a Web application, you must also delete the corresponding folders and servers under webapps. in the xml file, delete the xml file in the conf/catalina/localhost directory of Tomcat. Otherwise, Tomcat will still configure and load the file...

 

2. dynamic deployment

 

Log onto the tomcat Console: http://www.bkjia.com/, enter the user name and password to manage the application and dynamic publishing.

 

Enter/yourwebname in Context Path (option):, which indicates the access address of your application.

 

In the XML Configration file URL, you must specify an xml file. For example, you can create an hmcx file under F. xml file with the following content: <Context reloadable = "false"/> docBase does not need to be written because it is entered in the next text box. Or simply, enter F:/hmcx in the WAR or Directory URL, and click Deploy to view the web application, the name is the name in Context Path (option.

 

 

 

If you want to Deploy the. war file in a simpler way, you can click Select WAR file uploae to browse and Select the. war file, and then click Deploy.

 

From vatanoc's blog

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.