The build and run of Maven

Source: Internet
Author: User

Build:

Original address: http://www.cnblogs.com/candle806/p/3439469.html

Eclipse+maven Create WebApp Projects < a >

1, open Eclipse, right key new--"other, the following figure to find Maven project

2. Select Maven Project, display the window to create the MAVEN item, and tick the picture, create a simple project

3, enter the basic information of the MAVEN project, as shown in the following illustration:

4, to complete the creation of MAVEN project, generate the corresponding MAVEN project results, as shown below, there are some of the structure is not required by the project, we need to remove:

5, select the item, right key select Properties, go to the property page, select the Maven menu, as shown in the following image:

6, select the Java version of 1.7, and remove the other two, the following figure:

7, click OK, back to the project structure, at this time the project structure is more clear, in line with the MAVEN project we want to create

8, at this time WebApp results have not been shown, because at this time we have not configured this project for the Web project, again in the properties configuration, as shown in the following figure:

9, click further configuration available ..., as follows:

10, configure Src/main/webapp, and check the options to generate Web.xml, as follows:

11, after the confirmation, return to the Maven menu to remove dynamic Web module Check, click OK, as shown below, the WEBAPP directory structure is displayed:

12, at this point also need to configure, Src/main/webapp as the "/" project root directory, as follows:

13, complete as above configuration, the final completion of the MAVEN WEBAPP project structure as shown in the following figure:

In the final step, we'll point the current build path to Maven Dependency, click Add, select Java Build path Entries and then next

and then click Finish to complete

after the completion of the following figure:

a maven based WebApp is built and can be posted directly from eclipse to Tomcat


Run:

Table of Contents: method One: Using Maven's Plugin:jetty to deploy Web methods two: Using Eclipse's Jetty Plug-in Direct deployment method three: Using Run on Server (Tomcat) deployment

[Method one], using Maven's plugin:jetty to deploy

The first step: Configure the Pom.xml file

Configuring the Jetty plug-in in node <build><plugins>...</plugins></build> is dependent on the following: XHTML <plugin> <groupid >org.mortbay.jetty</groupId> <artifactId>maven-jetty-plugin</artifactId> <version> 6.1.26</version> <configuration> <webappsourcedirectory>${basedir}/src/main/webapp</ Webappsourcedirectory> </configuration> </plugin>

1 2 3 4 5 6 7 8 <plugin> <groupId> org.mortbay.jetty </groupId> <artifactId> maven-jetty-plugin </ artifactid> <version> 6.1.26 </version> <configuration> <webAppSourceDirectory> ${basedir }/src/main/webapp </webAppSourceDirectory> </configuration> </plugin>

Step Two: Configure the Goals parameter

Right-click the project –> Run as–> Maven build...–> Goals input: Jetty:run can:

Click the Run button that runs log information as follows: [INFO] scanning for projects ... [INFO] [INFO]------------------------------------------------------------------------[INFO] Building MyWeb Maven Webapp 0.0.1-snapshot [INFO]------------------------------------------------------------------------[INFO] [INFO] & Gt;&gt;&gt; Maven-jetty-plugin:6.1.26:run (DEFAULT-CLI) @ myweb &gt;&gt;&gt; [INFO] [INFO]---maven-resources-plugin:2.5:resources (default-resources) @ myweb---[debug] Execute contextualize [WARNING] U Sing platform encoding (UTF-8 actually) to copy filtered resources, i.e. builds is platform dependent! [INFO] Copying 0 resource [info] [INFO]---maven-compiler-plugin:2.3.2:compile (default-compile) @ myweb---[info] No sources t o compile [info] [INFO]---maven-resources-plugin:2.5:testresources (default-testresources) @ myweb---[Debug] execute C ontextualize [WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. builds is platform Depende Nt! [INFO] SkiP Non existing resourcedirectory D:\workspace_sun\maven-demo\myweb\src\test\resources [INFO] [INFO]--- Maven-compiler-plugin:2.3.2:testcompile (default-testcompile) @ myweb---[info] No sources to compile [info] [INFO] & lt;&lt;&lt; Maven-jetty-plugin:6.1.26:run (DEFAULT-CLI) @ myweb &lt;&lt;&lt; [INFO] [INFO]---maven-jetty-plugin:6.1.26:run (default-cli) @ myweb---[info] configuring jetty for Project:myweb maven WEBAP p [INFO] Webapp Source directory = D:\workspace_sun\maven-demo\myweb\src\main\webapp [info] Reload mechanic:automatic [I NFO] Classes = D:\workspace_sun\maven-demo\myweb\target\classes 2012-09-10 16:06:55.837:info::logging to STDERR via Org.mortbay.log.StdErrLog [INFO] Context Path =/myweb [INFO] TMP directory = determined at runtime [INFO] Web defaults = Org/mortbay/jetty/webapp/webdefault.xml [INFO] Web overrides = none [Info] Web.xml file = D:\workspace_sun\maven-demo\ Myweb\src\main\webapp\web-inf\web.xml [INFO] WebApp directory = D:\workSpace_sun\maven-demo\myweb\src\main\webapp [INFO] starting jetty 6.1.26 ... 2012-09-10 16:06:55.945:info::jetty-6.1.26 2012-09-10 16:06:56.082:info::no Transaction Manager found-if your webapp re Quires One, please configure one. [INFO] Started Jetty Server 2012-09-10 16:06:56.382:info::started selectchannelconnector@0.0.0.0:8080

2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 [INFO] Scanning for projects ... [INFO] [INFO]------------------------------------------------------------------------[INF O] Building myweb Maven Webapp 0.0.1-snapshot [INFO]------------------------------------------- -----------------------------[INFO] [INFO] & gt; & gt; & gt; Maven-jetty-plugin:6.1.26:run (DEFAULT-CLI) @ myweb & gt; & gt; & gt; [INFO] [INFO]---maven-resources-plugin:2.5:resources (default-resources) @ myweb---[Debug] Execute Contextu Alize [WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, I. E. Build is platform dependent! [INFO] Copying 0 resource [info] [INFO]---maven-compiler-plugin:2.3.2:compile (default-compile) @ myweb---[ Info] No sources to compile [info] [INFO]---maven-resources-plugin:2.5:testresources (Default-testreso UrcES)

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.