MAVEN's Concise tutorial (3)---Create engineering and basic commands in Eclipse introduction _maven

Source: Internet
Author: User
Tags log4j

[工欲善其事, its prerequisite]

In this article, we'll demonstrate using MAVEN to write a simplest application and use this program to illustrate how the basic commands commonly used by MAVEN are used.

Preparatory work:

A. Operating system: Win7 x64

B. Development tools: Eclipse Mars Java EE version, Maven3.3.2,jdk7-------------------------------------------------------------------- --------------------------------------------------------------------------------------------------------------- -----------

Body Start:

Part I: Creating a maven project in eclipse

1. Open Eclipse, select the file--->new--->other, and select Maven project. The following figure:


2. Click Next to enter the image below, the default option is unchanged, continue to click Next, enter the second image interface, select Artifact ID for QuickStart type, click Next



"At this point, if you need to create a Web project, select the last option in the previous illustration Maven-archetype-webapp and then click Next." 】

3. After clicking Next, go to the figure below, the data below the desired content.


Parameter meaning:

Group ID: organization name, such as Org.springframework

Artifact ID: Project name

Version: Edition number

Package: Default Package Name

4. Click Finish,eclipse to create a HelloWorld project for us. The construction diagram is as follows:. Here we need to switch the JRE version of the project from 1.5 to version 1.7. Step: Remove 1.5 from the libraries under build path, and then click the JRE System Library--->next--->finsh under add libraries. The result is shown in the second picture. We found that the JRE version of the project has been switched from 1.5 to 1.7.


5. Open the Pom.xml file. as follows:

 <project xmlns= "http://maven.apache.org/POM/4.0.0" xmlns:xsi= "Http://www.w3.org/2001/XMLSchema-instance" xsi:schemalocation= "http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" > < Modelversion>4.0.0</modelversion> <groupId>com.java.maven</groupId> <artifactId> Helloworld</artifactid> <version>0.0.1-SNAPSHOT</version> <packaging>jar</packaging > <name>HelloWorld</name> <url>http://maven.apache.org</url> <properties> ;p roject.build.sourceencoding>utf-8</project.build.sourceencoding> </properties> <dependencies
      > <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>3.8.1</version> <scope>test</scope> </dependency> </dependencies > </project> 
6. Landing Mavn Warehouse, http://mvnrepository.com/. Search for the name of the jar package we need. such as log4j. The search results are shown in the following illustration:

7. Select the first Apache log4j, in the pop-up page, click the version number we need to use. such as 1.2.17. pops up the following:


8. Paste the dependency in the following Maven box under Dependencys in the Pom.xml file.

9. Click Save and we can see the project MAVEN dependencies has joined the log4j jar package. The following figure:


10. At this point, we are adding a method to rely on the jar package to introduce the completion.

Special Remarks:

Sometimes, the jar packages that we need to rely on are dependent on other jar packages. At this point, we just need to introduce the jar package we want to use, and Maven will help us automatically download the dependent third party Jar pack. At this point, a third party jar package will appear under Maven dependencies, even if there are no dependencies in our pom file.

--------------------------------------------------------------------------------------------------------------- ------------------------------------------------------------------------------

Part II: MAVEN basic Command Introduction:

Note: The commands here are used at the command line.

A.MVN Compile: Compiling projects

B.MVN Test: Testing the Project

C.MVN Package: Package project, run and then view under target

D.MVN Install: Install the project to the local warehouse

E.MVN clean; Clear maven compiled files, run and then target to view

F.MVN Eclipse:eclipse: Converting a project to an Eclipse project

G;MVN jetty:run: Start jetty. Another example: Tomcat:run

--------------------------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------------

Here: Maven Concise tutorial (3)---Create Engineering and basic command introduction in Eclipse end

Note:

1. In eclipse, common commands can be used by using the right key project run as or debug as.

2. In eclipse, sometimes when we modify the project, or if there is an exclamation mark on the item, we can test it through the right key maven--->update project.




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.