The maven note: The Eclipse MAVEN project deploys debugging in TOMCAT7 and Jetty9

Source: Internet
Author: User
Tags tomcat server apache tomcat

Now the latest Eclipse Luna Release has built-in Maven plugin, 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 can be deployed in Tomcat can also be deployed on the jetty server , 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.

Four. Add the Jetty9 plugin to the Pom.xml file

1 Jetty can refer to the official documentation (HTTP://WWW.ECLIPSE.ORG/JETTY/DOCUMENTATION/CURRENT/JETTY-MAVEN-PLUGIN.HTML)

1 <plugin>2   <groupId>org.eclipse.jetty</groupId>3   < Artifactid>jetty-maven-plugin</artifactid>4  5 </plugin>

After the above steps are configured, enter the command at the command line:

MVN Jetty:run

You can access the project by entering http://127.0.0.1:8080/xpxiaowuApp/index.html in the browser.

2 Set (Modify) the Port of the jetty (Maven plug-in Maven-jetty-plugi), such as the following configuration document.

1<project xmlns="http://maven.apache.org/POM/4.0.0"Xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"2xsi:schemalocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">3<modelVersion>4.0.0</modelVersion>4<groupId>com.xinping</groupId>5<artifactId>TestWeb</artifactId>6<version>0.0.1-snapshot</version>7<packaging>war</packaging>8 9<!--unify the specified character set for the entire project--Ten<properties> One<project.build.sourceencoding>utf-8</project.build.sourceEncoding> A</properties> -  -  the<build> -<!--packaged War name set- -<finalName>TestWeb</finalName> -  +<pluginManagement> -<plugins> +                  A<plugin> at<groupId>org.mortbay.jetty</groupId> -<artifactId>maven-jetty-plugin</artifactId> -                      -<configuration> -<scanIntervalSeconds>3</scanIntervalSeconds> -<connectors> in<connector implementation="Org.mortbay.jetty.nio.SelectChannelConnector"> -<port>8888</port> to</connector> +</connectors> -                        the</configuration> *</plugin> $                 Panax Notoginseng</plugins> -</pluginManagement> the</build> +  A</project>

The maven note: The Eclipse MAVEN project deploys debugging in TOMCAT7 and Jetty9

Related Article

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.