Project Object Model

A maven project has a pom.xml file, through which the project coordinates, project dependencies, project information, plug-in goals, etc. are defined.

Dependency Management System (Dependency Management System)
through maven dependency management for the unified management of jar packages that the project depends on.
For example: The project depends on junit4.9, and junit4.9 is used by defining the dependency of junit4.9 in pom.xml, as shown below is the dependency definition of junit4.9:

<!-Dependencies-> 
    <dependencies> 
        <!-This project runs using junit, so this project depends on junit-> 
        <dependency> 
            <!-Junit project 
            name-> <groupId> junit </ groupId> 
            <!-junit module name-> 
            <artifactId> junit </ artifactId> 
            <!-junit version-> 
            <version> 4.9 </ version> 
            <!-Dependency range: use junit for unit testing -> 
            <scope> test </ scope> 
        </ dependency>

  A Project Lifecycle
uses maven to complete the project construction. Project construction includes: cleaning, compiling, testing, deploying and other processes. Maven standardizes these processes as a life cycle. The following are the stages of the life cycle:

 

 

Maven can implement various processes of the above life cycle by executing some simple commands, such as executing mvn compile to perform compilation, and mvn clean to perform cleaning.

A set of standard collections
maven defines a set of standards for the entire project management process, for example: a standard directory structure for a project built through maven, a standard life cycle stage, and standard coordinate definitions for dependency management.

Plugin (goal) goal
Maven management project life cycle process is based on plugins.

Four, dependent scope

A depends on B. The coordinates of B need to be added in the pom.xml file of A. When adding coordinates, you need to specify the dependent range.

compile: Compile scope, which means that A depends on B during compilation. This scope is the default dependent scope. Compile-range dependencies will be used for compilation, testing, and running. Compile-range dependencies will be packaged due to runtime requirements.

provided: The provided dependency is only used after the JDK or a container has provided the dependency. The provided dependency is required during compilation and testing, but not at runtime. For example, the servlet api is provided by the tomcat container.

runtime: The runtime dependency is needed when running and testing the system, but not when compiling. For example: jdbc driver package. Due to runtime requirements, runtime-wide dependencies will be packaged.

test: Test range dependencies are not required during compilation and operation, they are only available during test compilation and test operation, such as junit. Since it is not needed at runtime, the test scope dependency will not be packaged.

system: The system range dependency is similar to provided, but you must explicitly provide a path to the JAR file in the local system. You need to specify the systemPath disk path. System dependency is not recommended.

Guess you like

Origin www.cnblogs.com/sy211910/p/12710070.html