Java project management tool – maven

Here is the video tutorial:
http://www.imooc.com/learn/443


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
    Java project management tool - maven

    directory structure of Maven:
    Java project management tool - maven

  • Package is your code, such as top/wowdatat/example/HelloWorld.java
  • In addition, pom.xml and Src should be in the same directory
  • Pom.xml
    Java project management tool - maven
    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

Java project management tool - maven


提示build success后,代表编译成功。(第一次编译会下载 很多jar,时间较长)

Java project management tool - maven


编译成功后,会在根目录下生产一个target目录,下面有编译后的class

2) project execution: execute MVN test
under the
root directory

Java project management tool - maven

Java project management tool - maven


执行,并且执行

3) the project packs
MVN package
and generates a module named jar
in the target directory

Java project management tool - maven

4, Maven commonly used component commands

Java project management tool - maven

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)

Java project management tool - maven

Java project management tool - maven

Automatically create a variety of directories and pom.xml
, there is a way: directly enter various parameters, directly created, the effect is the same.

Java project management tool - maven

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:

Java project management tool - maven
< 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

Java project management tool - maven

Select the local Maven setting

Java project management tool - maven


jar的参数:

Java project management tool - maven

-Dmaven.multiModuleProjectDirectory=$M2_HOME
creates Maven project

Java project management tool - maven


编译

Java project management tool - maven


compile

Java project management tool - maven


或者package

Java project management tool - maven

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

Java project management tool - maven

8, actual combat: use Maven component web project (important)

Select webapp when you build a new project

Java project management tool - maven

New directory structure, and then configure the output directory in update project
buildpath

Java project management tool - maven


project facets中勾选dynamic web module

Java project management tool - maven

Deployment configuration, useless, such as test packages

Java project management tool - maven


使用jetty插件运行项目

Java project management tool - maven


使用tomcat插件运行项目

Java project management tool - maven

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.