Maven +tomcat+m2eclipse Thermal Deployment (Hot Deploy)

Source: Internet
Author: User

Original address: http://www.cnblogs.com/cbf4life/archive/2010/01/29/1659502.html

Software version: Maven 2.2 Tomcat 6.0,eclipse 3.4

The first is to build the environment, Tomcat, MAVEN, M2eclipse do not say, this does not deserve good, the rest of you do not look. are ready, then we will start one step at a pace.

    1. Manage your own tomcat.

To the Tomcat installation directory, where F:\J2EE\apache-tomcat-6.0.24\conf adds a user-defined, default is no user, the result is as follows:

<tomcat-users><user username= "admin" password= "password" roles= "manager"/></tomcat-users>

Added an admin user, password is password, role is administrator.

2. Start Tomcat, then Access http://localhost:8080/manager/html, enter Admin/password, and if the following interface appears, indicate that Tomcat is OK:

3. To define the native tomcat in Maven Setting.xml, add the following:

<servers><!--Add a test server--><server><id>tomcat</id><username>admin</ Username><password>password</password></server></servers>

Remember the ID here, and so will be used.

4. Build a MAVEN project in eclipse that has a package type of war:

If this is not the right step, then go ahead and practice maven again.

5. Modify the Pom.xml file in the following format:

<project xmlns= "http://maven.apache.org/POM/4.0.0" xmlns:xsi= "Http://www.w3.org/2001/XMLSchema-instance" xsi: schemalocation= "http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd" ><modelversion >4.0.0</modelversion><groupid>com.world</groupid><artifactid>demo</artifactid ><version>0.0.1-SNAPSHOT</version><packaging>war</packaging><build>< Plugins><plugin><groupid>org.codehaus.mojo</groupid><artifactid>tomcat-maven-plugin </artifactid><version>1.0-beta-1</version><configuration><url>http://localhost : 8080/manager/html</url><server>tomcat</server></configuration></plugin></ Plugins></build></project> 

Look at the configuration, nothing else.,<url> tag indicates the manager address of Tomcat,<server> the label indicates that the server is being used.

6. Add Web. XML and a test file hotdeplytest.jsp in the project.

Hotdeplytest.jsp content is as follows:

<%@ page language= "java" contenttype= "text/html; charset=gb18030 "pageencoding=" GB18030 "%><! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" "Http://www.w3.org/TR/html4/loose.dtd" >

Web. XML doesn't have any content, just copy it from another project.

7, the demo project, the right mouse button, Run as select Maven Build, the following interface appears:

Add something to goals: package Tomcat:redeploy

What do you mean by this sentence? The purpose of running the build is to package and deploy to Tomcat at the same time.

8, click the Run button, pay attention to the console, see if there is no error, no error, Access: http://localhost:8080/demo/HotDeployTest.jsp, if the following interface appears, it means everything:

Then you can begin to continue to ravage, to join the essence of yourself!

Maven +tomcat+m2eclipse Thermal Deployment (Hot Deploy)

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.