Tomcat project deployment method

Install the tomcat plugin

1. If there is no tomcat icon, you can open it in the following ways

2. Configure tomcat, select the path and version of the corresponding tomcat

3. Install the tomcat plugin and select Help first

4. Then select Install New Software

5. After the interface is displayed, click Add

6. Configure the name of the plugin and select the path corresponding to the plugin

Plugin file download address:

https://files.cnblogs.com/files/AmyZheng/net.sf.eclipse.tomcat.updatesite-2016-09-21.zip

Copy the web project files to the webapps directory

1. Copy the web project files directly to the webapps directory

  • Tomcat's Webapps directory is Tomcat's default application directory. When the server starts, all applications in this directory will be loaded.
  • So you can package the JSP program into a war package and put it in the directory, the server will automatically unpack the war package and generate a folder with the same name in this directory.
  • A war package is a jar package with a characteristic format, which is obtained by compressing all the contents of a web program.
  • Specifically how to package, you can use the IDE environment of many development tools, such as Eclipse. You can also use the cmd command: jar -cvf mywar.war myweb
  • You can also directly copy WebContent to the webapps directory and rename it to be the same as the project name
  • This method belongs to static deployment

Test Case:

Right-click and select Export---------->Select WAR file point next---------->Browser select export path------------- ---> Click finish to complete

 

2. Modify the default loaded directory

  • The default application directory of webapps can also be changed.
  • Open the server.xml file in the conf directory of Tomcat, find the following content, and modify the appBase.
<Host name="localhost"  appBase="webapps"
            unpackWARs="true" autoDeploy="true">

        <!-- SingleSignOn valve, share authentication between web applications
             Documentation at: /docs/config/valve.html -->
        <!--
        <Valve className="org.apache.catalina.authenticator.SingleSignOn" />
        -->

        <!-- Access log processes all example.
             Documentation at: /docs/config/valve.html
             Note: The pattern used is equivalent to using pattern="common" -->
        <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
               prefix="localhost_access_log" suffix=".txt"
               pattern="%h %l %u %t "%r" %s %b" />
</Host>

 Modify server.xml

1. Deploy a JSP application in a new Context in server.xml

  •   In Tomcat's configuration file, a Web application is a specific Context, and a JSP application can be deployed in a new Context in server.xml . Open the server.xml file, and build a Context in the Host tag with the following content:

 

        <Context path="/s" docBase = "D:\java_workspace\java\Servlet\WebContent" reloadable = "true" />
  • path is a virtual path;
  • docBase is the root directory of the actual storage location of the web page, mapped to the path virtual directory;
  • workDir is the working directory of this application, which stores the files related to this application generated at runtime;
  • debug is to set the debug level, 0 means to provide the least information, 9 means to provide the most information
  • When privileged is set to true, Tomcat's web application is allowed to use the servlet in the container
  • If reloadable is true, tomcat will automatically detect changes in the /WEB-INF/lib and /WEB-INF/classes directories of the application, automatically load new applications, and change applications without restarting tomcat. Implement hot deployment
  • This method belongs to static deployment

Create a Context file

1. In the conf directory, create a new Catalina\localhost directory, and create a new xml file in this directory

  • The name cannot be chosen arbitrarily, it must be the same as the name after the path
  • This method belongs to static deployment
<?xml version="1.0" encoding="UTF-8"?>
<Context docBase = "D:\java_workspace\java\Servlet\WebContent" reloadable = "true" >
</Context>

Dynamic deployment

1. Dynamic deployment means that the web application can be deployed after the server is started without restarting the server. First create a new s.xml in any directory

<?xml version="1.0" encoding="UTF-8"?>
<Context  reloadable = "true" >
</Context>

2. Start tomcat, enter http://localhost:8080 in the browser, select ManageApp, enter the password and user name, the user name and password settings refer to the blog http://www.cnblogs.com/AmyZheng/p/8735170.html

3. Enter the virtual path in Context Path(option): the same as the xml file name, such as: /s, specify a path of s.xml file in XML Configration file URL, and enter the path of war in WAR or Directory URL:.

4. Or choose to upload the war package in the following interface.

Reference blog link

https://blog.csdn.net/diamondy/article/details/7472411

For reprints, please indicate the source in an obvious place

http://www.cnblogs.com/AmyZheng/p/9013404.html

Guess you like

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