Deploy a Java Web project in Tomcat

Source: Internet
Author: User

1. Static deployment (deployed before the server is started)

A. Put the project under webapps.

B.ChangeIn the $ catalina_home \ conf \ Server. xml file, add the <context> tag to the <Context docbase = "D: \ javaspace \ SFA \ webroot" reloadable = "false" Path = "/sfa123"/>. You do not need to place the file under webapp,Reloadable = "false" indicates that when the applicationProgramAfter the content in is changed, the server will not automatically load it. This attribute is usually set to true in the development phase to facilitate development. It should be set to false in the release phase to speed up application access. Docbase is a path. You can use an absolute path or a relative path relative to webapps. The value of the path attribute is the root address during access. The access address is as follows: http: // localhost: 8080/Sfa123/

C.This method is similar to the second method, but instead of adding the context tag to the server. xml file$ Catalina_homeAdd an XML file, such as SFA. XML, to \ conf \ Catalina \ localhost. The content is as follows:
<Context docbase = "D: \ javaspace \ SFA \ webroot" reloadable = "false"/> you may find that the method is similar to the second method, but the path attribute is missing, in this way, the server will use. the XML name is used as the value of the path attribute. The access address is as follows: http: // localhost: 8080/SFA/(Never used)

We just deployed the SFA folder on the server. We know that we can pack the content of the Web application into a *. War package and then deploy it on the server.

Two Methods of jar package generation
Right-click the project name, select the war file type under Java EE, export the jar package or doscommand to enter the project file, and enter the following command: jar CVF SFA . War */.
(1) Change docbase = "D: \ javaspace \ SFA \" to docbase = "D: \ javaspace \ SFA. War"
(2) You can copy it directly to webapps.
Restart the server and deploy SFA. War as a web application.
If you are careful enough, you will find that the server unlinks the SFA. War file, creates an SFA folder under webapps, and then copies the content of SFA. War to it.
You can cancel the automatic unpackage as follows:
<Host name = "localhost" appbase = "webapps" unpackwars = "true" autodeploy = "true">
<! -- Change "unpackwars =" true "to" false "to" OK "->
<Context .... />

</Host>

2. dynamic deployment

 

 

Context path (option): Input/SFA
XML configration File URL: Specifies a. xml file. For example, we create an SFA. xml file under F: \ with the following content:
<Context reloadable = "false"/> docbase does not need to be written, because the Path entered in the next text box is. Or simply, this text box is left empty.
War or directory URL: type d: \ javaspace \ SFA \ webroot or c: \ Users \ Andy \ Desktop \ SFA. you can use war, and then click deploy to see if your web application has been seen above. The name is the name in your context path (option.
If you 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.

 

 

Http://www.blogjava.net/ocean07000814/articles/331694.html

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.