MAVEN's Tomcat plug-in Deployment Web project, I simply think that there are two kinds, one is to deploy to the built-in Tomcat, and the other is to deploy to the installation of Tomcat.
The first deployment, the default is the 8080 port deployed in the built-in Tomcat, if you do not need to change the port and other settings, you can not configure the Tomcat plugin in the POM
If you need to change the port, refer to the following configuration:
<Build> <Plugins> <plugin> <groupId>Org.codehaus.mojo</groupId> <Artifactid>Tomcat-maven-plugin</Artifactid> <version>1.1</version> <Configuration> <Path>/demo1</Path> <Port>8088</Port> <uriencoding>UTF-8</uriencoding> </Configuration> </plugin> </Plugins></Build>
then execute mvn clean tomcat:deploy, and finally MVN Tomcat:run can start the built-in Tomcat.
Built-in Tomcat deployment is simple, the following is mainly about the locally installed Tomcat deployment
1. Preparatory work
Download the installation and configure Tomcat and Maven.
Prepare a MAVEN Web project.
2. MAVEN deployment Web project to tomcat configuration
2.1. Configuring Tomcat
2.1 maven automatic deployment is actually tuned to the manager feature in the Tomcat installation directory. In order to access the Http://localhost:8080/manager page normally, we need to modify the Tomcat-users.xml in the $tomcat_home/conf directory:
<tomcat-users> <rolerolename= "Tomcat"/> <rolerolename= "Manager"/> <rolerolename= "Manager-gui"/> <rolerolename= "Manager-script" /> <rolerolename= "Admin-gui"/> <Userusername= "Tomcat"Password= "Tomcat"Roles= "Tomcat,manager, Manager-gui,manager-script,admin-gui" /></tomcat-users>
PS: Using MAVEN's Tomcat plug-in to deploy the project, my understanding is to invoke the Manager-script permission, execute the command in a script, Manager-gui should be the interface way to deploy, that is, like WebLogic to open the management page, Choose your project deployment after you finish. The individual feels that has the Manager-script authority to be possible.
2.2. Modify Maven's Settings.xml
Locate Settings.xml in the $USER_HOME/.M2 directory and add the server node:
<Servers> <Server> <ID>Tomcat</ID> <username>Tomcat</username> <Password>Tomcat</Password> </Server></Servers>
2.3. Modify Pom.xml add tomcat Maven Plugin
I use the tomcat6,pom.xml to add the following configuration:
...
<Build> <Plugins> <plugin> <groupId>Org.codehaus.mojo</groupId> <Artifactid>Tomcat-maven-plugin</Artifactid> <version>1.1</version> <Configuration> <Path>/demo1</Path> <Port>8080</Port> <uriencoding>UTF-8</uriencoding> <URL>Http://localhost:8080/manager/html</URL> <Server>Tomcatserver</Server> <username>Tomcat</username> <Password>Tomcat</Password> </Configuration> </plugin> </Plugins></Build>
If it is a TOMCAT7 plugin:
<Properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <spring.version>3.2.2.RELEASE</spring.version> <Finalname>Web-loab</Finalname> </Properties> <Build> <Plugins> <plugin> <groupId>Org.apache.tomcat.maven</groupId> <Artifactid>Tomcat7-maven-plugin</Artifactid> <Configuration> <URL>Http://localhost:8080/manager/text</URL> <Server>Tomcat</Server> <username>Tomcat</username> <Password>Tomcat</Password> <Path>/demo1</Path> </Configuration> </plugin> </Plugins> </Build>
Above username, password from tomcat-users.xml. The server's ID from the server specified by Settings.xml. Path is the way to access the app. The URL specifies the Tomcat Management page path.
2.4. Deploy the project to Tomcat
MVN Clean Tomcat:redeploy
Then MVN Tomcat:run can start the locally installed Tomcat with the plugin.
PS: In addition I heard that the MVN Tomcat plugin can only start a project, in practice, found that this is the case, but did not find information to confirm, we have comments and suggestions please enlighten.
Reference Document: http://my.oschina.net/feichexia/blog/326893
Deploying a project using the Tomcat plugin in an Eclipse MAVEN project