Use of Tomcat-maven-plugin [turn]

Source: Internet
Author: User

Environment:

Ubuntu 8.10, Tomcat6, mave2

Maven2 has a plug-in tomcat-maven-plugin that deploys Web applications to tomcat, and we can use this plug-in to deploy the Web application one-click to a remote Tomcat.

Url:http://mojo.codehaus.org/tomcat-maven-plugin/of Plug-ins

1. To turn on the Tomcat Manager feature

The point to note here is that if your Web application uses a virtual host, such as www.test.com, then you need to deploy the manager under Www.test.com. The deployment of virtual hosts and applications is not explained here.

Visit: http://www.test.com:8080/manager/html

You need to enter a username and password. If you do not know, please open the file tomcat_install_dir/conf/tomcat-users.xml, look for whether the user has the role of manager, most likely not, then add a user.

My tomcat-users.xml content is as follows:

<?xml version= ' 1.0 ' encoding= ' utf-8 '?>
<tomcat-users>
<role rolename= "Manager"/>
<user username= "Tomcat" password= "123456" roles= "manager"/>
</tomcat-users>

Restart Tomcat, visit http://www.test.com:8080/manager/html again, and now you know your username and password. On this page you can see all the www.test.com applications.

2, add in your Web application's Pom.xml file

<build>
<finalName>ROOT</finalName>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>tomcat-maven-plugin</artifactId>
<configuration>
<url>http://www.test.com:8080/manager</url>
<server>test</server>
<path>/</path>
</configuration>
</plugin>
</plugins>
</build>

Finalname here is set to root, so MVN package generated war file name is Root.war, what name is actually indifferent.

This is configured with the URL of the Tomcat manager for the publishing application, and the application is to be deployed at the root/bottom. However, there is no user name and password configured, which is related to <server>test</server>. Here the user name and password are configured in other external files, to avoid different circumstances have modified pom.xml.

By default, if my login username is Arthur, you need to edit the file/home/arthur/.m2/settings.xml, which reads:

<?xml version= "1.0" encoding= "UTF-8"?>
<settings>
<servers>
<server>
<id>test</id>
<username>tomcat</username>
<password>123456</password>
</server>
</servers>
</settings>

The original can be configured like this

3, Operation

MVN Tomcat:deploy or

MVN Tomcat:redeploy

Visit: http://www.test.com:8080/manager/html, to see if the application is ready for deployment.

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.