Automate packaging and deployment to Linux servers using maven (TOMCAT7)

Source: Internet
Author: User

Recently using MAVEN, by the way, try the next Tomcat deployment. Find a lot of information on the internet but are not up-to-date, so paste a relatively new TOMCAT7 deployment code and configuration, easy to review and test OK later.

1. First, configure the Tomcat-users.xml in the Tomcat conf directory, configure user rights, and provide it to local maven

  <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 username= "Tomcat" password= "Tomcat" roles= "Manager-gui,manager-script,manager-jmx,manager-status, Admin-script,admin-gui "/>

Note: At first I only configured Manager-gui this role, in the local no problem, can normally log on to Http://127.0.0.1/manager, but access to Http://127.0.0.1/manager/text, So if you need to configure a friend can put my this copy of the past.

A successful login indicates that the Tomcat permissions have been configured, followed by the local maven configuration.

2. My MAVEN project uses aggregation engineering, so I added this plugin to the parent Pom project, Tomcat6 I haven't tried, so I don't know if it's OK.

<!--remote Deployment-        <plugin>            <groupId>org.apache.tomcat.maven</groupId>            < artifactid>tomcat7-maven-plugin</artifactid>            <version>2.2</version>            < Configuration>                <url>http://xxxxxx.xx.xxx:8082/manager/text</url>                < server>test</server>                <username>tomcat</username>                <password>tomcat</ password>            </configuration>        </plugin>

Explain that ur l is the directory under which you want to deploy the port Tomcat, not the project. TOMCAT7 default this, if is 6 is not add text

3. Next is the configuration of the settings.xml file in Maven, which is simple and the code is as follows:

<server>        <id>test</id>        <username>tomcat</username>        <password> Tomcat</password>      

Note: The ID here corresponds to the server in the MAVEN project Pom.xml, and the other username and password are consistent, that is, the username and password of the tomcat login.

4. If the above configuration is OK, and finally the test, I am the aggregation project here, so I am going to my sub-project to run the Publish command. Remember to make sure you start tomcat early if you want to release it, or you will get an error.

PS: In this process there are two obvious problems, one is 401, the other is 403.

401: Basically the user name or password configuration is incorrect.

403: There are two cases,

1): The URL suffix configured in pom is HTML, not text. This is the 6 format, 7 is not available, the suffix can only be text.

<url>http://localhost:8080/manager/html</url>

2): Tomcat user's permissions are not configured correctly. The configuration is OK in this article.

Also, Tomcat should start first, do not start with the IDE, and manually run Tomcat's startup.bat/sh.

It's OK.

Automate packaging and deployment to Linux servers using maven (TOMCAT7)

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.