The MAVEN project uses external TOMCAT7 and makes remote hot deployment __java

Source: Internet
Author: User

Reproduced from: http://m.blog.csdn.net/blog/jrn1012/38610495


In MAVEN project development, it is generally recommended to use jetty for development and debugging. However, when the project was released, it was required to use TOMCAT7 as the publisher, and a TOMCAT7 plug-in was configured in Maven to support the project for remote thermal deployment of the external TOMCAT7.

Specific configuration steps are as follows:

1, install TOMCAT7 in the server segment, and change the configuration folder conf tomcat-users.xml. This allows the user tomcat to have administrator privileges.

<span style= "FONT-SIZE:14PX;" ><role rolename= "Admin-gui"/> <role rolename= "admin-script"/> <role "rolename=
" Manager-gui "/> <role rolename=" Manager-script "/> <role rolename=
" manager-jmx "/>
< Role rolename= "Manager-status"/>
<user name= "Tomcat" password= "Tomcat" roles= "Manager-gui,manager-script" , Manager-jmx,manager-status,admin-script,admin-gui "/></span>

2, in the local maven setttings.xml file, add the following configuration in the attribute <servers><servers>

    <server>
		<id>tomcat7</id>
		<username>tomcat</username>
		<password >tomcat</password>
    </server>

3, in the project Pom.xml introduced the Tomact7-maven-plugin plug-in, and the plug-in configuration

< Plugin> <groupId>org.apache.tomcat.maven</groupId> <artifactid>tomcat7-maven-plugin</  Artifactid> <version>2.2</version> <configuration> <!--Note that the URL--> <!-- <url>http://localhost:18080/manager/text</url>--><!--deployed to local tomcat7--> <url>http://
					IP address:8080/manager/text</url> <server>tomcat7</server> <!--The name here must be the same as the ID configured in Setting.xml--> <path>/${projectName}</path> <!--The name here is the project name--> <!--<username>tomcat</usernam e>--><!--settings.xml files are configured to be--> <!--<password>tomcat</password>--><!-- Settings.xml files are configured to be--> </configuration> </plugin> 

4. Perform the MVN tomcat7:deploy command (first deployment) on the current project, or MVN Tomcat7:redeploy (deploy again) so that the project is successfully deployed at remote Tomcat. (Note: Make sure TOMCAT7 is started before deployment)

To sum up, complete the remote hot deployment of TOMCAT7, do not forget tomcat7 server.xml configuration uriencoding= "UTF-8" in order to support Chinese. As follows:

      <connector port= "8080" protocol= "http/1.1" connectiontimeout= "20000" redirectport= "8443"
               UTF-8 "/>

If you want the directory of your project to be the root of tomcat7, so that the project does not have to be started with the project name access, such as http://ip/project name, changed to HTTP://IP can be added in Server.xml <Host> <context Path= "" docbase= "" "Debug=" "0" reloadable= "true"/>. The directory for this project becomes the root directory, not the root directory.

       also has a way of not changing the Server.xml configuration, which is to <path>/${projectname}</path in Pom.xml > instead <path>/ROOT</path>, the project is published as a root directory, except that the test found that only Root.war was generated remotely and no root folder was generated. And you need to manually start the root directory project in the manager interface. deployment to local (localhost) did not find this problem.

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.