Here is the video tutorial:
1, Maven introduction
Baidu Encyclopedia: the Maven project object model (POM), a software project management tool that manages project construction, reporting, and documentation through a small section of descriptive information.
Person to person explanation: Maven is a java project management tool, mainly used for jar package management, project packaging, publishing and so on.
2, Maven download and install
1, Download maven
2, configure the environment variables, including
- M2_HOME: configuring the directory of maven
- Then path
increased%M2_HOME%/bin; CMD test: mvn-v
directory structure of Maven:
- Package is your code, such as top/wowdatat/example/HelloWorld.java
- In addition, pom.xml and Src should be in the same directory
example: where groupid is the life insurance, artifactid is the name of the module, the version version of dependencies is below jar is dependent on the
editor after pom.xml in the project directory (with Src in the same directory)
3. Compile, execute and package the project
1) the project compiles
in the project root and executes the MVN compile
提示build success后，代表编译成功。（第一次编译会下载 很多jar，时间较长）
2) project execution: execute MVN test
3) the project packs
and generates a module named jar
in the target directory
4, Maven commonly used component commands
These commands can also be entered directly into several, such as MVN, clean, compile, direct clean, and compile operations.
automatically creates a directory skeleton: the archetype plug-in (which is not available in practice, using IDE)
Automatically create a variety of directories and pom.xml
, there is a way: directly enter various parameters, directly created, the effect is the same.
5, Maven update image
The default is a foreigner warehouse built, China is relatively slow, in order to get faster access, you can use the warehouse, such as the aliyun
Maven program: open the conf/settting.xml directory, as shown below:
< mirror> < id> nexus-aliyun< /id> < mirrorOf> *< /mirrorOf> < name> Nexus aliyun< /name> < url> http://maven.aliyun.com/nexus/content/groups/public< /url> < /mirror>
6, eclipse’s Maven configuration
Select the Maven directory
Select the local Maven setting
creates Maven project
7, Maven plug-in
Plugin library address: http://maven.apache.org/plugins
, for example, use the source plug-in: source package
, specify the package at the same time, the implementation of source packaging
8, actual combat: use Maven component web project (important)
Select webapp when you build a new project
New directory structure, and then configure the output directory in update project
project facets中勾选dynamic web module
Deployment configuration, useless, such as test packages
Coding in the rain, coding anywhere, coding my life.
to understand some front-end, understand some back-end program ape, is also the product concerned dog, big data, artificial intelligence, focus attention all the interesting things.
, this is raincoding. Like to pay attention to me.