MAVEN Eclipse Configuration

Source: Internet
Author: User

1. Use of Maven

Maven is a project building and management tool that provides methods to help manage builds, documentation, reporting, dependencies,scms, publishing, and distribution. It is easy to compile code, manage dependencies, manage binaries, and more.

the benefit of MAVEN is the ability to standardize, automate, and efficiently integrate project processes with strong scalability

with maven itself and its plug-ins, you can also get code review reports, unit test coverage, continuous integration, and more.

2, the main application of the project

Packaged deployment

Mandatory and accurate jar package management and automatic download

Automatic source and document download auto-correlation

Auxiliary testing

3, POM

Pommeans thatProject Object Model. Pomis aXML, inmavenin thePom.xml. is amavenwork on the basis of the implementation ofTaskorgoalwhen themavenwill go to the project root directory to readPom.xmlGet the configuration information you need

The pom file contains information about the project and the configuration information required by the Maven build project, usually with project information ( such as version, Member ), Project dependencies, plugins and goal,build options , and more

Pom can be inherited, usually for a large project or multiple modules, the submodule Pom needs to specify the parent module's Pom

4, the meaning of the node in the Pom file is as follows

top-level elements of the project Pom File

modelversion The object model version used , this element is mandatory in order to ensure stable use. No modifications are required unless MAVEN developer upgrades the template

groupId is a unique identifier for a project to create a community or organization, usually a domain name inverted

such as : GroupId org.apache.maven.plugins

Artifactid is the unique site name of the project artifact

Packaging Artifact packaging methods such as jar,war,ear , etc. The default is jar. This is not only the file that indicates what suffix the project ultimately produces, it also indicates What lifecycle the build process uses .

versions of version artifact, which are usually seen as similar to 0.0.1-snapshot, where SNAPSHOT represents project development, for development version

name represents the display name of the project, used in the MAVEN -generated document

URL represents the address of the project, which is used in a MAVEN -generated document

Description represents a description of a project, used in a MAVEN -generated document

Dependencies represents dependencies, adding specific dependent groupId artifactid and version in child node dependencies

Build represents the build configuration

Parent represents the parent Pom

5, artifact

This is a little bit difficult to explain, roughly speaking is a project will be produced by the file, can be jar files, source files, binaries,war files, even pom files. Each artifact is uniquely identified by an identifier consisting of groupId:artifactId:version. Artifact that need to be used ( dependent ) are placed in the warehouse ( See Repository) in

6.Repositories

The repositories is used to store Artifact . If our project produces Artifact is a small tool, then repositories is a warehouse, which has our own tools to create, can also store other people made tools, When we need to use some kind of tool in our project, we declare dependencyin the Pomand compile the code according to dependency go to download tool ( Artifact ) for your own use.

You can put the project into the warehouse (repositories) with the MVN install command after you have completed your project

warehouses are divided into local warehouses and remote warehouses, and remote warehouses are used for storage on remote servers Artifact Warehouse, the local warehouse refers to the warehouse of the native storage Artifact , for the Windows machine Local Warehouse address is the system user . m2 /repository below.

for the required dependencies, add dependency in the Pom and you can

Maven 's Warehouse search:http://mvnrepository.com/

7. Maven Build

7.1 Preparation Tools

Apache-maven-3.0.4-bin.gz

Eclipse IDE for Java EE developers Mars Latest

7.2. Unpack the package to D drive

7.3. Then unzip the library into the apche-maven-3.0.4 package.

7.4 Setting up Maven settings in eclipse

Click Browse to select Setting.xml under the Conf folder in the MAVEN package.

7.4. Then click Open File

7.5 appears below, select Source in the lower left corner, find the contents of the red box, copy the location of the MAVEN library

<localRepository>D:/apache-maven-3.0.4/Repository</localRepository> Note Yes/, Save it.

7.6. The structure of MAVEN project and the post-compilation structure

The src is a required folder , Pom.xml is a required distribution file

Main is a required folder where all the source files are stored

Java java text widget

Resources Placement Profiles

The test is stored in the test code .

7.7 Common Commands

unit tests in the MVN test run program

MVN compile compiling the project

MVN install is packaged and installed to the local warehouse, this time the native warehouse will be added

MVN eclipse:clean purge eclipse project Files

7.8. Create a MAVEN project

MAVEN Eclipse Configuration

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.