A Java Engineering--maven Foundation

Source: Internet
Author: User
Tags configuration settings

MAVEN read [? Mev?n] translated to Chinese is "expert, experts"

I. What is MAVEN?

1. Development History of package dependencies: Original jar package import->ant->maven. is a project management tool.

2. Advantages:

  • The Convention over configuration convention is better than the configured; This principle is not only used in Maven, but is currently followed by most frameworks such as MVC.
  • Simple
  • Easy to test
  • Build Simple
  • CI (Continuous integration)
  • Rich Plugins

Two. Download and install

Download: http://maven.apache.org/download.cgi

Installation: Unzip the installation

To configure environment variables:

  • Windows path Maven_home
  • Linux. Bash_profile
  • The run parameter is set by the environment variable maven_opts
  • Configuration settings.xml settings.xml file is an empty template, we can do some custom configuration here, such as repo storage directory <localrepository>,mirror mirror address, and proxy configuration < Proxies>, plug-in <plugingroups>, configuration (username, password, etc.) <servers> Environment <profile>

Search Order:

Three. Create a MAVEN project

  • Project structure conventions better than configuration

  • Pom.xml

GROUPID Company Organization

Artifactid function naming

Version number

Packaging packaging method, default jar;

Dependancymanagement It is best to only appear in the parent Pom, for the unified version number, only to make the declaration of dependency, sub-module use also need to reference, but do not need to do version specified.

Dependancy

Type default jar

SCOPE specifies which stage to use

  1. Complie compiled, packaged by default such as Spring-core
  2. Test tests such as Spring-test
  3. Provided compilation such as Servlet
  4. Runtime runtime, such as the JDBC Driver implementation package
  5. Some jar on system local
  6. Dependency delivery
  7. Relying on the arbitration, (1) The shortest path principle, according to the dependency tree, the closest to the nearest version of the dependency tree, (2) load order principle, the same path in order of loading priority; (3) Exclusions exclusion package

Version number update plug-in, otherwise require each module to modify Pom

Command: mvn dependancy:tree View dependency tree

Four. Maven life cycle (three processes)

Distinguishing terms: Lifecycle phase goal

Clean contains the phase:pre-clean-> clean–> Post-clean

Default compile package install deploy ....

Site Pre-site->site->post-site–> Site-deploy

1. A build Lifecycle is made up of phases a building life cycle is composed of multiple phase

2. A build Phase is made up of Plugin goals a building Phase is composed of multiple plug-in target goal

A Java Engineering--maven Foundation

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.