Maven’s detailed tutorial

Time:2020-10-11

summary:

1. Maven is essentially a project management tool, which abstracts the process of project development and management into a project object model (POM).
  2. Maven is a build tool contributed by Apache open source organization.

Summary:

1. Maven manages all the dependency packages in a unified and centralized way, so programmers don't need to look for them.
  2. For common jars used by third-party components, Maven automatically solves the problems of duplication and conflict.
  3. As an open architecture, Maven provides a common interface to facilitate integration with third-party plug-ins. Programmers can dynamically integrate their plug-ins into Maven to extend new management functions.
  4. Maven can unify the construction process of each project and realize the compatibility management of different projects

Download, install, and configure the environment

References:

  • Download, install and configure Maven environment for MAC system

Introduction to the standard directory structure:

References:

  • Introduction of Maven standard directory structure

Maven’s directory structure is different from traditional projects. The following is the directory structure that a jar package usually has.
Maven's detailed tutorial
Src / main / Java: source code directory

Src / main / resources: resource file directory

Src / test / Java: test code directory

Src / test / resources: test resource file directory

This is only part of the structure, such as jar or war project. If the source code is generally this structure, but this structure is not necessary. Different projects and different requirements can have different structures.

The following is the expected directory structure given by maven, and the Maven project is created according to this structure by using templates, so we try to comply with this specification.
Maven's detailed tutorial
Let’s look at the directory structure of a jar project
Maven's detailed tutorial
Among them, Maven dependencies are all dependent jar packages. Target directory is the temporary directory file generated by packaging, including class files, test related files, and generated jar packages. POM file is the core configuration file of Maven project

POM.XML

pom.xml  Is Maven's configuration file, usually in the root directory.

Maven project structure:

Introduction of official documents Maven project structure

Command:

Get help: mvn -h

mvn -P:Activate profile in profiles, use, split list.

Execute the MVN command corresponding to the phase: mvn <phase>
                  . Available lifecycle phases

Execute MVN plugin (goal)

  1. mvn somePrefix:[email protected]

    1. Someprefix indicates the prefix of plugin name, usually the following prefix:

      • maven-${prefix}-plugin
      • ${prefix}-maven-plugin
    2. Goal is the goalname in < goal > goalname < goal >
    3. Executionid is the idname in < ID > idname < / ID > under < execution >
  2. mvn groupId:artifactId:version:[email protected]

    1. Version is not required

Recommended Today

Building micro service governance ecosystem based on monitoring service

Based on the previous article《Micro service massive log monitoring platform》Introduce the platform architecture, continue to optimize the architecture and function expansion, realize the service governance ability. Problem status Log monitoring platform brings us a lot of convenience to solve online problems. However, to a certain extent, it only provides us with clues, and the final […]