Use of Tomcat-Maven-plugin [go to]

Source: Internet
Author: User

Environment:

Ubuntu 8.10, Tomcat 6, mave2

 

Maven2 has a plug-in that deploys a web application to Tomcat. We can use this plug-in to deploy the web application to a remote Tomcat with one click.

 

Plug-in URL: http://mojo.codehaus.org/tomcat-maven-plugin/

 

1. To enable the Tomcat Manager function

Note that if your web application uses a virtual host such as www.test.com, You need to deploy the manager under www.test.com. The deployment of virtual hosts and applications is not described here.

 

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

Enter the user name and password. If you do not know, open the fileTomcat_install_dir/CONF/tomcat-users.xml, find to see if there is a User Manager role, it is likely that there is no, 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 and access http://www.test.com again: 8080/manager/html, now you know your username and password. On this page, you can see all the applications at www.test.com.

 

2. Add the following content to the Pom. xml file of your web application:

<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 is set to root, so the name of the war generated by MVN package is root. War.

The Tomcat Manager URL for publishing an application is configured here,
And the application must be deployed under the root. However, the user name and password are not configured, which is related to <Server> test </Server>. Enter the user name and password
It is configured in other external files to avoid modifying Pom. XML in different environments.

By default, if my login username is Arthur, you need to edit the file/home/Arthur/. m2/settings. XML with the following content:

 

<? XML version = "1.0" encoding = "UTF-8"?>
<Settings>
<Servers>
<Server>
<ID> test </ID>
<Username> Tomcat </username>
& Lt; password & gt; 123456 & lt;/password & gt;
</Server>
</Servers>
</Settings>

 

You can configure it like this.

 

3. Run

MVN Tomcat: deploy or

MVN Tomcat: redeploy

Visit: http://www.test.com: 8080/manager/html to see if the application is deployed?

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.