Now the latest Eclipse Luna Release has built-in Maven plug-in, which makes our work a lot more concise, as long as the project directly into the can, regardless of the plug-in problems, but after the import of the project needs to be deployed under Tomcat debugging, the following is the debugging process.
I. Development environment
Java:jdk7
Eclipse:eclipse Java EE IDE for Web developers, Version:luna Release (4.4.0)
maven:3.2.5
Tomcat:7
Two. Configuring Tomcat users
The TOMCAT7 and 8 configuration user rights are the same, and more information can be found in the official documentation (http://tomcat.apache.org/). Also configure the standalone server to modify Tomcat's tomcat-user.xml file, adding user permissions.
1 <rolerolename= "Manager-gui"/>2 <rolerolename= "Admin-gui"/>3 <UserPassword= "Admin"Roles= "Manager-gui,Admin-gui, Manager-script"username= "Admin"/>
Where Manager-gui and Admin-gui are Tomcat's management interface, manager-script refers to the user rights rules that maven plugins can access
Three. Add the Tomcat plugin to the Pom.xml file
TOMCAT7 can refer to the configuration of the Maven plugin in the official documentation (HTTP://TOMCAT.APACHE.ORG/MAVEN-PLUGIN-2.2/).
1 <Build>2 3 <pluginmanagement>4 <Plugins>5 <plugin>6 <groupId>Org.apache.maven.plugins</groupId>7 <Artifactid>Maven-war-plugin</Artifactid>8 <version>2.1.1</version>9 <Configuration>Ten <Webxml>Src/main/webapp/web-inf/web.xml</Webxml> One </Configuration> A </plugin> - - <plugin> the <groupId>Org.apache.tomcat.maven</groupId> - <Artifactid>Tomcat7-maven-plugin</Artifactid> - <version>2.2</version> - <Configuration> + <URL>http://localhost:8080/xpxiaowuApp/</URL> - <username>Admin</username> + <Password>Admin</Password> A </Configuration> at </plugin> - - </Plugins> - </pluginmanagement> - - </Build>
On line 19th, the Web app's deployment address in Tomcat.
Three. The Maven plugin that runs TOMCAT7
After the above steps are configured, enter the command at the command line:
MVN Tomcat7:run
If all goes well, a hint will appear.
D:\workspace_maven>mvn Tomcat7:run[info] scanning forprojects ... [INFO] [INFO]------------------------------------------------------------------------[INFO] Building Xpxiaowuapp0.0.1-Snapshot[info]------------------------------------------------------------------------[Info][info]>>> Tomcat7-maven-plugin:2.2: Run (default-CLI) > process-Classes @ Xpxiaowuapp>>>[Info][info]---maven-resources-plugin:2.6: Resources (default-resources) @ Xpxiaowuapp---[WARNING] Using platform encoding (GBK actually) to copy filtered resources, i.e. build isPlatform dependent![INFO] Copying0Resource[info][info]---maven-compiler-plugin:3.1: Compile (default-compile) @ Xpxiaowuapp---[INFO] nothing to compile-All classes is up to Date[info][info]<<< Tomcat7-maven-plugin:2.2: Run (default-CLI) < process-classes @ Xpxiaowuapp <<<[Info][info]---tomcat7-maven-plugin:2.2: Run (default-CLI) @ Xpxiaowuapp---[INFO] Running War on http://Localhost:8080/xpxiaowuapp[INFO] Using existing Tomcat server configuration at D:\workspace_maven\target\tomcat[info] Create WebApp with Contex Tpath:/Xpxiaowuapp May -, - 9: -: Apm Org.apache.coyote.AbstractProtocol init info: Initializing Protocolhandler ["http-bio-8080"] May -, - 9: -: Apm Org.apache.catalina.core.StandardService startinternal Info: Starting service tomcat May -, - 9: -: Aafternoon Org.apache.catalina.core.StandardEngine startinternal info: Starting Servlet engine:apache Tomcat/7.0. -May -, - 9: -: -pm Org.apache.coyote.AbstractProtocol Start Info: Starting Protocolhandler ["http-bio-8080"]
You can see the Welcome page by entering http://localhost:8080/xpxiaowuApp/in the browser.
Note: The experiment proves that the above steps are also successfully configured in TOMCAT8.
Deployment debugging in the Eclipse Maven project TOMCAT7