Jetty and Tomcat several ways to run MAVEN Web projects

Source: Internet
Author: User

Catalogue

1. Introduction

2. Run the Maven Web project with Jetty and Tomcat

1. Introduction

In the previous article we introduced the MAVEN Web project created with Eclipse, and then we describe how to run the MAVEN Web project to facilitate our development and debugging, which is used in the form of the maven plugin, so that the coupling is relatively low, What kind of tools we need to introduce the corresponding plug-in can be used.


2. Run the Maven Web project with Jetty and Tomcat

     1) jetty run maven web project

First step: Install the jetty plugin on Eclipse, first Eclipse help->install new softwareCentral location:http://run-jetty-run.googlecode.com/svn/trunk/updatesite/

Tick the option and wait for it to download and install, and then restart Eclipse when you're done .


Step Two: maven Project Pom.xml add Jetty plug-in Jetty-maven-plugin, we want to run the Test-maven-console project, so to add in this project Pom.xml

<plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> &LT;ARTIFACTID&G T;maven-compiler-plugin</artifactid> <configuration> <source>${version.jdk}</so Urce> <target>${version.jdk}</target> <showwarnings>true</showwarnin Gs><compilerarguments><verbose/><bootclasspath>${java.home}\lib\rt.jar;${java.home}\lib\ Jce.jar</bootclasspath></compilerarguments> </configuration> </plugin&           Gt          <plugin><!--clean-djetty.port=9090 Jetty:run-<groupId>org.mortbay.jetty</groupId> <artifactId>jetty-maven-plugin</artifactId> <configuration> <reload>a Utomatic</reload> <scanIntervalSeconds>10</scanIntervalSeconds> <systemproperti Es> </systemproperties> <useTestClasspath>true</useTestClasspath> <webAppConfig>        <contextPath>/</contextPath> </webAppConfig> </configuration> </plugin><pre name= "code" class= "java" style= "FONT-SIZE:18PX;" ></plugins>

Description: Maven-compiler-plugin This plugin is a compile plugin

Step Three: Configure the run port and so on. Click the Test-maven-console Project right-click Run as-->run configurations and then click Jetty WebApp Right click on the new configuration jetty version and Port ports (

Not port conflicts )

Click Run to see if the console has an error, if not error on behalf of the success of the operation

We can also launch in dug form, so that we could track the project.

2. run the Maven Web project with Tomcat

  first step: The eclipse side does not need to introduce tomcat plug-ins, The tomcat plug-in will be introduced directly in the project to be run, test-maven-console project Tomcat plugin tomcat6-maven-plugin  (To2.0versionTomcat-maven-pluginis now split intoTomcat7-maven-pluginand theTomcat6-maven-pluginout, andgroupIdalso byOrg.codehaus.mojoinsteadOrg.apache.tomcat.maven. Our side is using theTomcat6-maven-plugin

Test-maven-console in the pom.xml.

    <!--Tomcat Run clean tomcat6:run-<plugin> <groupid>org.apache.tomcat.maven</grou          Pid> <artifactId>tomcat6-maven-plugin</artifactId> <version>2.2</version> <configuration><!--http Port-to-<port>9090</port> <!--application path alway S starts with/--> <path>/</path> <uriEncoding>UTF-8</uriEncoding> <systempro Perties> <java.io.tmpdir>${project.build.directory}</java.io.tmpdir> </syst emproperties> </configuration> </plugin> <plugin><!--Clean Cargo:rede Ploy-<groupId>org.codehaus.cargo</groupId> <artifactid>cargo-maven2-plugin</ artifactid> <configuration> <container> <containerid>tomcat6x</co           Ntainerid>   <type>remote</type> </container> <configuration> <type&gt ;runtime</type> </configuration> </configuration> </plugin>

Description

1.port Port number

2.path to/This does not include the project name when accessing

Step Three: Configure run, click test-maven-console Project Run As-->run configurations then click on MAVEN build right click New in goals enter Tomcat6:run then click Run Check the console for any errors.




At this time no error in the background, indicating that it can run normally

Maven offers a lot of plugins

                    <plugin><groupid>org.apache.maven.plugins</groupid><artifactid>maven-resources-plugin </artifactId><version>2.6</version></plugin><!--Install plugin--><plugin>< Groupid>org.apache.maven.plugins</groupid><artifactid>maven-install-plugin</artifactid> <version>2.4</version></plugin><!--Clean Plugin--><plugin><groupid> Org.apache.maven.plugins</groupid><artifactid>maven-clean-plugin</artifactid><version> 2.5</version></plugin>

More commonly used plugins


To summarize:

Running MAVEN Web projects is commonly used in both of these runs, and Tomcat runs maven Web projects can also take another, we usually less use, here is not specifically described in detail,

Using the Tomcat:redeploy command, publish the Maven Web project to an externally launched T-omcat for testing

When using MAVEN to introduce jar package, sometimes I will not find, here I encountered in the MAVEN use of the problem (dependent on the jar file download failure, etc.) are introduced, I hope to help.


Jetty and Tomcat several ways to run MAVEN Web projects

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.