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
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
- Complie compiled, packaged by default such as Spring-core
- Test tests such as Spring-test
- Provided compilation such as Servlet
- Runtime runtime, such as the JDBC Driver implementation package
- Some jar on system local
- Dependency delivery
- 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