Maven environment quick build 2 (eclipse + maven2 + jetty)

Source: Internet
Author: User

This document updates a command.

The first section prompts you to create a project using archetype: Create create is an obsolete or not recommended plug-in. Please try to use archetype: generate in future projects.

Create a project as follows:

MVN archetype: generate-dgroupid = com. chongshi. Test-dartifactid = Hello

-Dpackagename = com. chongshi. Test-dversion = 1.0

The first section throws three problems. This article will solve the first two problems.

1. How to CreateWebProject

2. How to UseJetteyContainer running

IfMavenI do not know the basic configuration of. Please read the first article.Article:

Http://www.cnblogs.com/fnng/archive/2011/12/02/2272610.html

----- // Create a Text Project

 

1. How to CreateWebProject.

In fact, it is very simple, just adding a parameter darchetypeartifactid to a common project. The command is as follows:

MVN archetype: generate-dgroupid = com. chongshi. Test-dartifactid = mywebapps-darchetypeartifactid = Maven-Archetype-webapp-dversion = 1.0

Go to the directory where the project is createdEclipseProject:

F: \ mywebapp>MVN Eclipse: Eclipse

 

After Maven is built, the project directory required by eclipse is as follows.

This article does not explainStruts2Project Creation and configuration, so do not writeStruts2But in order not to affect the subsequent contentStruts2OfWebProject

Example: http://www.mkyong.com/struts2/struts-2-hello-world-example/.

Download project source code:

Http://www.mkyong.com/wp-content/uploads/2010/08/Struts2-Hello-World-Example.zip

I decompress the package to a local device.DIn the root directoryMavenProject format, so you do not need to runMVN Eclipse:EclipseCommand to build. Import directlyEclipseTool. The project directory structure is as follows:

 

 

 
---- // How to use the jetty container

2.How to UseJettyContainer running project.

Use addJettyRun the project.

JettyAndTomcatAlso belongsWebContainer.JettyDoMavenAs a plug-in. We wantPom. xmlAddJettyCan be calledJetty.

In<Project>... </Project>Insert the following information between tags:

 

 <  Build  > 
< Finalname > Struts2example </ Finalname >
< Plugins >
< Plugin >
< Groupid > Org. mortbay. Jetty </ Groupid >
< Artifactid > Maven-jetty-plugin </ Artifactid >
< Version > 6.1.10 </ Version >
< Configuration >
< Scanintervalseconds > 10 </ Scanintervalseconds >
< Stopkey > Foo </ Stopkey >
< Stopport > 9999 </ Stopport >
</ Configuration >
< Executions >
< Execution >
< ID > Start-Jetty </ ID >
< Phase > Pre-integration-test </ Phase >
< Goals >
< Goal > Run </ Goal >
</ Goals >
< Configuration >
< Scanintervalseconds > 0 </ Scanintervalseconds >
< Daemon > True </ Daemon >
</ Configuration >
</ Execution >
< Execution >
< ID > Stop-Jetty </ ID >
< Phase > Post-integration-test </ Phase >
< Goals >
< Goal > Stop </ Goal >
</ Goals >
</ Execution >
</ Executions >
</ Plugin >
</ Plugins >
</ Build >

 

Run MVN jetty: jetty in the project directory.

 

D: \ Java \ Administrator \ workspace3 \ struts2example>MVN jetty: jetty

Waiting for the plug-in to download slowly(Poor network speed)I went to the toilet and poured water. I had a chat with my friends in the group.^_ ^ !!

After the plug-in is downloaded, it can run.JettyRun the following command:MVN jetty: Run 

Then we can access ourJSPPage.

 

Restart Jetty, Press the keyboardCTRL + cFollow the promptsY

 

 

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.