Tomcat has officially provided a MAVEN plugin for deploying MAVEN-based Web applications, different versions of Tomcat use different plug-ins, different versions of the use of the plug-in is also a certain difference, the details can be consulted http://tomcat.apache.org/maven-plugin.html . The following is the configuration process for deploying a Maven Web App in TOMCAT7 using Tomcat maven Plugin-2.2 in the Eclipse environment:
- First step: Configure the Tomcat Manager User:
Open Tomcat_user.xml in the Conf directory under the Tomcat root directory, add Manager roles and users under the <tomcat-users> node, and use the Tomcat Maven plugin to deploy the app automatically, with the following XML code:
<tomcat-users> <role rolename= "Manager-gui"/> <role rolename= "Manager-script"/> <user Us Ername= "Tomcat" password= "123456" roles= "Manager-gui, Manager-script"/> <!--user name and password can be other string legal string--></ Tomcat-users>
- Step Two: Maven To Add the Tomcat Server in the configuration:
Open maven's settings.xml file, if it is a locally installed version of MAVEN, the file is installed in the root directory conf/settings.xml, if you are using the eclipse built-in maven, the file is the current system user Directory/ . M2/setting.xml. Configure the manager user information for Tomcat under the <servers> node, with the following XML code:
<servers> <server> <id>myTomcat</id> <username>tomcat</username> <password>123456</password> </server><servers>
The ID is used to configure the server in the Pom.xml file, with the user name and password Tomcat_user.xml in the same configuration.
- Step Three: Configure the Tomcat Maven plugin plugin:
Open the project Pom.xml file and add the Tomcat Maven plugin plugin under the <plugins> node with the following XML code:
<plugins> <plugin> <groupId>org.apache.tomcat.maven</groupId> <artifactId>tomcat7-maven-plugin</artifactId> <version>2.2</version> < configuration> <url>http://localhost:8080/ manager/text</url> <!-- tomcat Management path --> <server>myTomcat</server> <!-- Same as the server ID in the settings.xml file --> <path>/myapp</path> <!-- Deployment locations for Applications --> </configuration> </Plugin><plugins>
- Fourth Step : deploy the app to TOMCAT7:
To start Tomcat, it is important to note that the default deployment location for Tomcat configured in Eclipse is in the metadata directory of workspace (without modifying the success of my deployment), which needs to be modified to the installation directory. Modify the method to open the configuration file by double-clicking Tomcat in the server view, and then save it by selecting the "Use Tomcat Installation" option in "Server Locations".
Select the project in Project view, right-click "Run as", "Maven bulid", execute Tomcat7:deploy command, you can complete the deployment, execute tomcat7:redeploy to redeploy the project, andtomcat7:undeploy Uninstall the deployment.
The above is my reference to the online information using TOMCAT7 Maven plugin deployment Web application records, the wrong place also ask you crossing correct!
Original address: http://www.gogogogo.me/development/Tomcat-Maven-Plugin-Tomcat7.html
Tomcat maven plugin deploying Maven Web Apps