guodefu909
deploy the MAVEN project in Eclipse to Tomcat
In fact, the MAVEN project deployed to Tomcat many ways, I from the beginning of the war package to the Tomcat/webapps directory, to use the Tomcat-maven plug-in, to the direct use of servers deployment, all the way to go through a lot of detours.
Here are a few of these deployment options:
1. Fight the war package to the Tomcat/webapps directory
This is not the same as the non-MAVEN project, but the way it's packaged
The war package is then generated under the target directory, and is replicated to the Tomcat/webapps directory to complete the deployment.
2. Using the Tomcat-maven plugin, add the following code to the </dependencies> after Pom.xml and make the appropriate changes
1 <build> 2 <finalName>guoguo-maven-web</finalName> 3 <plugins> 4 <PLUGIN&G
T 5 <!--3 Available plugins--6 <groupId>org.apache.tomcat.maven</groupId> 7 <ARTIFAC tid>tomcat6-maven-plugin</artifactid> <!--commands Tomcat6:redeploy-8 <!--&L T;groupid>org.apache.tomcat.maven</groupid>-9 <!--<artifactid>tomcat7-maven-plugin</ Artifactid>-<!--command for Tomcat7:redeploy, <!--<groupid>org.codehaus.mojo</groupi D>-<!--<artifactId>tomcat-maven-plugin</artifactId>-<!--command for TOMCAT:R Edeploy <!--<version>2.2</version> <configuration> &L t;! --<url>http://localhost:8080/manager</url> <!--TOMCAT6 Deployment Management path--<ur L>http://localHost:8080/manager/text</url> <!--TOMCAT7 Deployment Management path--<username>admin</user Name> <!--Tomcat Administrator account--<password>admin</password> 18 <port>8080</port> <path>/guoguo-maven-web</path> <!--deployment Path--<charset>UTF-8</charset> <encoding>utf-8</encoding>
; <!--before running the redeploy command, you should be able to access http://localhost:8080/manager--> </configuration> < /plugin> </plugins> </build>
This configures the Tomcat Maven plugin
Before running the redeploy command, start Tomcat and have access to the Http://localhost:8080/manager
With the project right-click Run as--and Maven build ...--and fill in the Tomcat6:redeploy command in goals, the deployment succeeds, which sometimes causes Tomcat to make an error, and the need to restart Tomcat
3. Deploy directly using servers
First make sure the build configuration is OK
Test directory compiled to Target/test-classes, other compiled to the Target/classes directory, other general default does not need to change what
Then deploy the configuration:
Once configured, by right-clicking Servers in Tomcat,add and remove ... Add Items and restart Tomcat
The first one I don't have anymore, the second is for direct deployment to the test server, and the third is for local debugging
Appendix:
Tomcat administrator configuration, add the following configuration in the Tomcat-users.xml of the servers project, if you are using Bin/startup.bat to start Tomcat directly, modify the Conf/tomcat-users.xml
----------TOMCAT6 Administrator Configuration----------
<role rolename= "Manager"/>
<user username= "admin" password= "admin" roles= "manager"/>
----------TOMCAT6 Administrator Configuration----------
----------TOMCAT7 Administrator Configuration----------
<role rolename= "Manager-script"/>
<role rolename= "Manager-gui"/>
<user username= "admin" password= "admin" roles= "Manager-gui,manager-script"/>
----------TOMCAT7 Administrator Configuration----------