Maven core concepts (2)

Maven coordinates

    Mainly used to identify a unique package in dependencies.

    Coordinates consist of four elements:

    1.groupId: Defines the project to which the current Maven project belongs.

    2.artifactId: A module that defines the project.

    3.version: version number.

    4.packing: packaging method, the default is jar package.

dependency management

In the pom.xml file, the way of declaring dependencies is as follows: The
 
     dependency scope scope is used to control the relationship between dependencies and the ClassPath that is compiled, tested, and run. The main dependencies are as follows:

    1.compile: It is valid for compiling, testing and running the three ClassPaths. If the scope option is not set, it will default to this scope, such as log4j.

    2.test: Only valid for test ClassPath, such as: Junit

    3.provided: The dependency scope has been provided, which is valid for the ClassPath for compilation and testing, but invalid for running. Because it depends on the existing container, such as Servlet-API.

    4.runtime: Provided at runtime, such as jdbc driver.

warehouse management

    Maven repository: The location used to uniformly store all Maven shared builds is the repository, such as: ~\.m2\repository\

    Warehouse layout: Define the unique storage path of each component in the warehouse according to Maven coordinates, groupId /artifactId /version /artifactId-version.packing

    Warehouse classification:

         1. Local warehouse.

         2. Remote warehouse.

                     Remote repositories also include:

                         a. Central warehouse: Maven's default remote warehouse. http://repo1.maven.org/maven2

                         b. Private server: It is assumed that the warehouse is in the local area network.

                         cj mirror: used to replace the remote warehouse, generally faster than the central warehouse.

The life cycle

    The Maven declaration cycle is used to abstract and unify all build processes. This build process includes build steps such as project cleanup, initialization, compilation, packaging, testing, and deployment.

    Maven has three independent lifecycles:

        Clean Lifecycle does some cleanup before doing the real build.

        The core part of the Default Lifecycle build, compile, test, package, deploy, and more.

        Site Lifecycle generates project reports, sites, publishing sites.

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326706937&siteId=291194637
Recommended