What is Maven?

Nowadays we need to use many third-party libraries to build a project. For example, writing a Web project using Spring requires importing a large number of JARS. The number of JARS in a project is often staggering, and the relationship between jars is complicated. One Jar often references other JARS, and the absence of any Jar will cause the project to fail to compile. In the past, when developing projects, programmers often need to spend more energy in reference to Jar packages to build the project environment, and this work is particularly difficult, one Jar package less, one Jar package often reported some confusing exceptions. Maven is a tool to help programmers build projects. We just need to tell Maven which Jar packages we need, and it will help us download all the JARS, greatly improving development efficiency.

Directory structure specified by Maven

To use Maven, the project’s directory structure must conform to Maven’s specifications

Maven basic commands

-v: Queries the Maven version

Check whether Maven is successfully installed. After the Maven installation is complete, enter MVN -v on the CLI. If Maven information is displayed, the installation is successful.

Compile the compile:

Compile Java source files into class files

Test: indicates a test project

Execute the test case in the test directory

Package: a package

Jar the project

Clean: remove

Delete target folder

Install: installation

Put the current project into Maven’s local repository. For other projects

What is Maven repository?

The Maven repository is used to store all jars managed by Maven. Divided into: local warehouse and central warehouse.

Local repository

Maven’s native Jar repository.

The central warehouse

Remote repository provided by Maven.

When a project is compiled, Maven first looks for the Jar packages needed for the project from the local repository, and then downloads the required JARS from Maven’s central repository if they are not available.

What are “coordinates”?

In Maven, coordinates are the unique identification of Jar packages, and Maven uses coordinates to find the Jar packages needed for a project in the repository. In the following code, groupId and artifactId form the coordinates of a Jar package.

<dependency>
    <groupId>ch.qos.logback</groupId>
    <artifactId>logback-classic</artifactId>
    <version>1.1.1</version>
</dependency>
Copy the code
  • GroupId: Project name of the required Jar package
  • ArtifactId: module name of the required Jar package
  • Version: indicates the version number of the required Jar package

Pass dependencies and exclude dependencies

  • Pass dependencies: If our project references a Jar package that in turn references another Jar package, Maven downloads both directly and indirectly referenced Jars locally by default when the project is compiled.
  • Exclude dependencies: If we only want to download directly referenced Jar packages, we need to do the following configuration in pom.xml: (Write the coordinates of the Jar packages to exclude in)
<exclusions>
    <exclusion>
        <groupId>ch.qos.logback</groupId>
        <artifactId>logback-classic</artifactId>
    </exclusion>
</exclusions>
Copy the code

Rely on the conflict

Dependency conflicts can occur when multiple jars in a project reference the same Jar at the same time, but Maven uses two conflict-avoidance strategies, so there are no dependency conflicts in Maven.

  • Short circuit is preferred
This project -- >A.jar -- >B.jar -- >X. Jar this project -- >C.jar -- >X.jarCopy the code

If the project references A.jar, A. Jar also references B. Jar, B. Jar also references X. Jar, and C. Jar also references X. Jar. At this point, Maven will only reference the Jar with the shortest path reference.

  • Statement is preferred

If the reference path is of the same length, whoever is declared first in pom.xml is used.

The aggregation

  • What is aggregation? Running multiple projects at the same time is called aggregation.

  • How is aggregation implemented? Just do the following configuration in the POM to achieve aggregation:

<modules>
    <module>. / module 1</module>
    <module>. / module 2</module>
    <module>. 3 / module</module>
</modules>
Copy the code

inheritance

  • What is inheritance?

When aggregating multiple projects, if the same JARS need to be introduced in the aggregated projects, these jars can be written to the parent POM, from which each child project inherits.

  • How is inheritance implemented?
  1. Parent POM configuration: Just put the coordinates of the Jar package you want to inherit into the label.
<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.apache.shiro</groupId>
            <artifactId>shiro-spring</artifactId>
            <version>1.2.2</version>
        </dependency> 
    </dependencies>
</dependencyManagement>
Copy the code
  1. The child pom configuration
<parent>
    <groupId>GroupId of the project where the parent POM is</groupId>
    <artifactId>ArtifactId for the project in which the parent POM is located</artifactId>
    <version>The version number of the project where the parent POM resides</version>
</parent>
Copy the code

Pom. XML, rounding

<project xmlns="http://maven.apache.org/POM/4.0.0"     
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"     
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0http://maven.apache.org/maven-v4_0_0.xsd">     
    <! -- Coordinates of the parent project. If the value of an element is not specified in the project, the corresponding value in the parent project is the default value for the project. Coordinates include the Group ID, artifact ID, and Version. -->    
    <parent>    
     <! -- Component identifier of inherited parent project -->    
     <artifactId/>    
     <! -- Globally unique identifier of the inherited parent project -->    
     <groupId/>    
     <! -- Version of inherited parent project -->    
     <version/>    
     <! -- The relative path to the parent project's POM.xml file. Relative paths allow you to choose a different path. The default value is.. / pom. XML. Maven first looks for the PARENT project's POM where the current project is built, then at this location in the file system (the relativePath location), then in the local repository, and finally in the remote repository. -->    
     <relativePath/>    
 </parent>    
 <! Declare which POM model version the project descriptor follows. The version of the model itself rarely changes, but it is still essential to ensure stability when Maven introduces new features or other model changes. -->       
    <modelVersion>4.0.0</modelVersion>     
    <! A globally unique identifier for a project, usually using a fully qualified package name to distinguish this project from other projects. The relative path generated by com.mycompany.app is: /com/mycompany/app-->     
    <groupId>cn.erhuowang</groupId>     
    <! -- Component identifier, which, along with the group ID, uniquely identifies a component. In other words, you can't have two different projects with the same Artifact ID and groupID; The Artifact ID must also be unique under a particular group ID. A artifact is something that a project produces or uses, and Maven produces artifacts for a project: JARs, source code, binary publishing, WARs, etc. -->     
    <artifactId>erhuowang-maven2</artifactId>     
    <! -- Artifact types generated by the project, such as JAR, WAR, EAR, POM Plug-ins can create their own component types, so not all of the component types listed above -->     
    <packaging>war</packaging>     
    <! -- The current version of the project, in the format of Major version. Incremental version - Limited version ->     
    <version>1.0 the SNAPSHOT</version>     
    <! -- Project name, maven-generated document used -->     
    <name>erhuo-maven</name>     
    <! -- Project home page URL, maven-generated documents used -->     
    <url>http://erhuowang.cn</url>     
    <! A detailed description of the project, used for maven-generated documentation. When the element can be described in HTML format (for example, if the text in CDATA is ignored by the parser, the HTML label can be included), plain text descriptions are discouraged. If you need to modify the index page of the resulting Web site, you should modify your own index page file, not adjust the document here. -->     
    <description>A maven project to study maven.</description>     
    <! -- describes the prerequisites in the build environment for this project. -->    
 <prerequisites>    
  <! -- The lowest version of Maven required to build the project or use the plug-in -->    
    <maven/>    
 </prerequisites>    
 <! -- Project name and URL-->     
    <issueManagement>    
     <! -- Project name, -->     
        <system>erhuowang</system>     
        <! -- The URL used for this project -->    
        <url>http://erhuowang.cn</url>     
    </issueManagement>     
    <! -- Project continuous Integration information -->    
 <ciManagement>    
  <! -- Name of continuous integration system like Continuum -->    
  <system/>    
  <! -- the URL of the continuous integration system used by the project, if the continuous integration system has a Web interface. -->    
  <url/>    
  <! Configuration items that need to be notified to developers/users when the build is complete. Includes notification information and notification conditions (error, failure, success, warning) -->    
  <notifiers>    
   <! -- Configure a way to notify users/developers when a build breaks -->    
   <notifier>    
    <! -- Way of sending notifications -->    
    <type/>    
    <! -- Whether to notify when errors occur -->    
    <sendOnError/>    
    <! Build failure notification -->    
    <sendOnFailure/>    
    <! Build success notification -->    
    <sendOnSuccess/>    
    <! -- Whether to notify when a warning occurs -->    
    <sendOnWarning/>    
    <! -- Disapproves of its use. Where to send notifications -->    
    <address/>    
    <! -- Extension configuration items -->    
    <configuration/>    
   </notifier>    
  </notifiers>    
 </ciManagement>    
 <! -- Project creation year, 4 digits. This value is needed when generating copyright information. -->    
    <inceptionYear/>    
    <! -- Project related mailing list information -->     
    <mailingLists>    
     <! This element describes all mailing lists associated with the project. Automatically generated websites reference this information. -->     
        <mailingList>     
         <! -- The name of the message -->    
            <name>Demo</name>     
            <! -- Email address or link, if it is an email address, the mailto: link will be created automatically when creating the document -->     
            <post>[email protected]</post>     
            <! Mailto: link will be created automatically when the document is created.     
            <subscribe>[email protected]</subscribe>     
            <! -- Unsubscribe the email address or link. If it is an email address, the mailto: link will be created automatically when the document is created.     
            <unsubscribe>[email protected]</unsubscribe>     
            <! -- You can browse the URL of the email message -->    
            <archive>[email protected]</archive>     
        </mailingList>     
    </mailingLists>     
    <! -- Project Developer List -->     
    <developers>     
     <! -- Information about a project developer -->    
        <developer>     
         <! -- unique identifier of project developer in SCM -->    
            <id>HELLO WORLD</id>     
            <! -- Full name of project developer -->    
            <name>chaimm</name>     
            <! -- Project developer's email-->    
            <email>[email protected]</email>     
            <! -- Project developer's home page URL-->    
            <url/>    
            <! -- The role of the project developer in the project. The role element describes various roles.    
            <roles>     
                <role>Project Manager</role>     
                <role>Architect</role>     
            </roles>    
            <! -- Organization of project developer -->    
            <organization>demo</organization>     
            <! -- URL of project developer's organization -->    
            <organizationUrl>http://erhuowang.cn</organizationUrl>     
            <! -- Project developer attributes, such as how to handle instant messages -->    
            <properties>     
                <dept>No</dept>     
            </properties>    
            <! -- The project developer's time zone, an integer ranging from -11 to 12. -->    
            <timezone>- 5</timezone>     
        </developer>     
    </developers>     
    <! -- List of other contributors to the project -->     
    <contributors>    
     <! -- Other contributors to the project. See developers/ Developer element -->    
     <contributor>    
   <name/><email/><url/><organization/><organizationUrl/><roles/><timezone/><properties/>    
     </contributor>         
    </contributors>       
    <! This element describes the list of all licenses for the project. Only the license list of this project should be listed. Do not list the license list of dependent projects. If multiple licenses are listed, the user can select one of them instead of accepting all licenses. -->     
    <licenses>    
     <! This element describes the project's license, the license page of the web site used to generate the project, and other reports and validations. -->     
        <license>    
         <! -- The legal name of the license -->    
            <name>Apache 2</name>     
            <! URL of the official license body page -->    
            <url>http://www.baidu.com/erhuwoang/LICENSE-2.0.txt</url>     
            <! The main method of project distribution: repO. Manual can be downloaded from Maven library. Users must manually download and install dependencies.    
            <distribution>repo</distribution>     
            <! Additional information about the license -->    
            <comments>A business-friendly OSS license</comments>     
        </license>     
    </licenses>     
    <! The Source Control Management (SCM) tag allows you to configure your code base for use by Maven Web sites and other plug-ins. -->     
    <scm>     
        <! The URL of the SCM, which describes the repository and how to connect to it. For more details, see the URL format and list provided by SCMs. The connection is read-only. -->     
        <connection>     
            scm:svn:http://svn.baidu.com/banseon/maven/banseon/banseon-maven2-trunk(dao-trunk)      
        </connection>     
        <! Connection element for developers. That is, the connection is not just read-only -->    
        <developerConnection>     
            scm:svn:http://svn.baidu.com/banseon/maven/banseon/dao-trunk      
        </developerConnection>    
        <! -- Tag of current code, default at development stage is HEAD-->    
        <tag/>           
        <! URL to a browsable SCM library (such as ViewVC or Fisheye) that points to the project. -->     
        <url>http://svn.baidu.com/banseon</url>     
    </scm>     
    <! Describe the various attributes of the organization to which the project belongs. Maven generates files using -->     
    <organization>     
     <! -- Full name of organization -->    
        <name>demo</name>     
        <! -- Organization home page URL-->    
        <url>http://www.erhuowang.cn</url>     
    </organization>    
    <! -- Information needed to build the project -->    
    <build>    
     <! This element sets up the project source directory, which the build system compiles when building a project. This path is a relative path to POM.xml. -->    
  <sourceDirectory/>    
  <! This element sets up the project script source directory, which is different from the source directory: in most cases, the contents of this directory will be copied to the output directory (because scripts are interpreted, not compiled). -->    
  <scriptSourceDirectory/>    
  <! This element sets up the source directory to use for the project's unit tests, which the build system will compile when testing the project. This path is a relative path to POM.xml. -->    
  <testSourceDirectory/>    
  <! -- The directory where the compiled application class files are stored. -->    
  <outputDirectory/>    
  <! The directory where the compiled test class files are stored. -->    
  <testOutputDirectory/>    
  <! -- Using a series of build extensions from the project -->    
  <extensions>    
   <! Describe the build extensions used. -->    
   <extension>    
    <! -- Build extended groupId-->    
    <groupId/>    
    <! -- Build extension artifactId-->    
    <artifactId/>    
    <! Build the extended version -->    
    <version/>    
   </extension>    
  </extensions>    
  <! -- Default value when the project does not specify a target (Maven2 is called phase) -->    
  <defaultGoal/>    
  <! This element describes the path list of all project-related resources, such as project-related properties files, that are included in the final package file. -->    
  <resources>    
   <! This element describes all project-related or test-related resource paths.    
   <resource>    
    <! -- describes the target path of a resource. The path relative to the target/classes directory (for example, ${project. Build. OutputDirectory}). For example, if you want to resources in a specific bag (org, apache maven. Messages), you must set this element to org/apache/maven/messages. However, if you just want to put resources into the source directory structure, this configuration is not required. -->    
    <targetPath/>    
    <! -- Whether to use parameter values instead of parameter names. Parameter values are taken from the properties element or configured in the file listed in the Filters element. -->    
    <filtering/>    
    <! -- Describe the directory where the resource is stored, relative to the POM path -->    
    <directory/>    
    <! -- A list of included schemas, such as **/*.xml.-->    
    <includes/>    
    <! -- A list of excluded schemas, such as **/*.xml-->    
    <excludes/>    
   </resource>    
  </resources>    
  <! This element describes all the resource paths associated with unit tests, such as the properties files associated with unit tests. -->    
  <testResources>    
   <! This element describes all resource paths related to the test. See build/ Resources/Resource element for a description.    
   <testResource>    
    <targetPath/><filtering/><directory/><includes/><excludes/>    
   </testResource>    
  </testResources>    
  <! -- Directory where all files generated by the build are stored -->    
  <directory/>    
  <! The default value is ${artifactId}-${version}. -->    
  <finalName/>    
  <! -- List of filter properties files to use when filtering is turned on -->    
  <filters/>    
  <! -- Default plug-in information that subprojects can reference. The plug-in configuration item is not resolved or bound to the lifecycle until it is referenced. Any local configuration for a given plug-in overrides the configuration here -->    
  <pluginManagement>    
   <! -- A list of plug-ins used. -->    
   <plugins>    
    <! The Plugin element contains the information needed to describe the plug-in. -->    
    <plugin>    
     <! -- Group ID of plugin in repository -->    
     <groupId/>    
     <! -- Artifact ID of the artifact in the repository -->    
     <artifactId/>    
     <! -- The version (or version range) of the plug-in being used -->    
     <version/>    
     <! -- Whether to download Maven extensions (such as packaging and type handlers) from the plugin. For performance reasons, this element is set to Enabled only if the download is actually needed. -->    
     <extensions/>    
     <! Perform configuration of a set of targets during the build life cycle. Each target may have a different configuration. -->    
     <executions>    
      <! The execution element contains the information needed to execute the plug-in.    
      <execution>    
       <! An identifier of the execution target, used to identify the target during the build process, or to match the execution target that needs to be merged during the inheritance process.    
       <id/>    
       <! -- Bind the build lifecycle phase of the target. If omitted, the target will be bound to the default phase configured in the source data.    
       <phase/>    
       <! -- Execution target of configuration -->    
       <goals/>    
       <! Is the configuration propagated to the child POM?    
       <inherited/>    
       <! -- Configuration as a DOM object -->    
       <configuration/>    
      </execution>    
     </executions>    
     <! -- Additional dependencies needed by the project to introduce plug-ins -->    
     <dependencies>    
      <! -- See dependencies/dependency element    
      <dependency>.</dependency>    
     </dependencies>         
     <! Is any configuration propagated to subprojects?    
     <inherited/>    
     <! -- Configuration as a DOM object -->    
     <configuration/>    
    </plugin>    
   </plugins>    
  </pluginManagement>    
  <! -- List of plugins used -->    
  <plugins>    
   <! - see the build/pluginManagement/plugins/plugin elements -- -- >    
   <plugin>    
    <groupId/><artifactId/><version/><extensions/>    
    <executions>    
     <execution>    
      <id/><phase/><goals/><inherited/><configuration/>    
     </execution>    
    </executions>    
    <dependencies>    
     <! -- See dependencies/dependency element    
     <dependency>.</dependency>    
    </dependencies>    
    <goals/><inherited/><configuration/>    
   </plugin>    
  </plugins>    
 </build>    
 <! Build profiles in column items, if activated, modify build processing -->    
 <profiles>    
  <! Activate a build process based on environment parameters or command line parameters -->    
  <profile>    
   <! -- Unique identifier for the build configuration. Both for command line activation and for merging profiles with the same identifier during inheritance. -->    
   <id/>    
   <! Automatic triggering of profile conditional logic. Activation is the key to a profile. The power of profiles comes from their ability to automatically use certain values in certain contexts; These environments are specified by the activation element. The activation element is not the only way to activate a profile. -->    
   <activation>    
    <! -- Profile activation flag by default -->    
    <activeByDefault/>    
    <! When a matching JDK is detected, the profile is activated. For example, 1.4 activates JDK1.4, 1.4.0_2, and! 1.4 Activate all JDK versions that do not start with 1.4. -->    
    <jdk/>    
    <! The profile is activated when a matching operating system attribute is detected. The OS element can define a number of operating system-specific attributes. -->    
    <os>    
     <! -- The name of the operating system to activate the profile -->    
     <name>Windows XP</name>    
     <! -- Activate profile operating system family (e.g. 'Windows ')-->    
     <family>Windows</family>    
     <! Activate the profile operating system architecture -->    
     <arch>x86</arch>    
     <! Activate the operating system version of the profile -->    
     <version>5.1.2600</version>    
    </os>    
    <! The Profile is activated if Maven detects a property whose value can be referenced by ${name} in the POM, and it has the corresponding name and value. If the value field is empty, the presence of the attribute name field activates the profile, otherwise match the attribute value field case-sensitive -->    
    <property>    
     <! -- The name of the attribute to activate the profile -->    
     <name>mavenVersion</name>    
     <! -- Activate the value of the profile property -->    
     <value>The 2.0.3</value>    
    </property>    
    <! -- Provide a file name to activate the profile by detecting its presence or absence. Missing Checks whether the file exists and activates the profile if it does not. Exists, on the other hand, checks whether a file exists and activates the profile if it does. -->    
    <file>    
     <! If the specified file exists, activate the profile. -->    
     <exists>/usr/local/hudson/hudson-home/jobs/maven-guide-zh-to-production/workspace/</exists>    
     <! If the specified file does not exist, activate the profile. -->    
     <missing>/usr/local/hudson/hudson-home/jobs/maven-guide-zh-to-production/workspace/</missing>    
    </file>    
   </activation>    
   <! -- Information needed to build the project. See build element -->    
   <build>    
    <defaultGoal/>    
    <resources>    
     <resource>    
      <targetPath/><filtering/><directory/><includes/><excludes/>    
     </resource>    
    </resources>    
    <testResources>    
     <testResource>    
      <targetPath/><filtering/><directory/><includes/><excludes/>    
     </testResource>    
    </testResources>    
    <directory/><finalName/><filters/>    
    <pluginManagement>    
     <plugins>    
      <! - see the build/pluginManagement/plugins/plugin elements -- -- >    
      <plugin>    
       <groupId/><artifactId/><version/><extensions/>    
       <executions>    
        <execution>    
         <id/><phase/><goals/><inherited/><configuration/>    
        </execution>    
       </executions>    
       <dependencies>    
        <! -- See dependencies/dependency element    
        <dependency>.</dependency>    
       </dependencies>    
       <goals/><inherited/><configuration/>    
      </plugin>    
     </plugins>    
    </pluginManagement>    
    <plugins>    
     <! - see the build/pluginManagement/plugins/plugin elements -- -- >    
     <plugin>    
      <groupId/><artifactId/><version/><extensions/>    
      <executions>    
       <execution>    
        <id/><phase/><goals/><inherited/><configuration/>    
       </execution>    
      </executions>    
      <dependencies>    
       <! -- See dependencies/dependency element    
       <dependency>.</dependency>    
      </dependencies>    
      <goals/><inherited/><configuration/>    
     </plugin>    
    </plugins>    
   </build>    
   <! Modules (sometimes called subprojects) are built as part of a project. Each module element listed is a relative path to the directory pointing to that module -->    
   <modules/>    
   <! Discover a list of remote repositories with dependencies and extensions. -->    
   <repositories>    
    <! -- See Repositories /repository element -->    
    <repository>    
     <releases>    
      <enabled/><updatePolicy/><checksumPolicy/>    
     </releases>    
     <snapshots>    
      <enabled/><updatePolicy/><checksumPolicy/>    
     </snapshots>    
     <id/><name/><url/><layout/>    
    </repository>    
   </repositories>    
   <! Discover a list of remote repositories for plugins used for building and reporting    
   <pluginRepositories>    
    <! Contains the information you need to connect to the remote plug-in repository. See also repositories/repository element -->        
    <pluginRepository>    
     <releases>    
      <enabled/><updatePolicy/><checksumPolicy/>    
     </releases>    
     <snapshots>    
      <enabled/><updatePolicy/><checksumPolicy/>    
     </snapshots>    
     <id/><name/><url/><layout/>    
    </pluginRepository>    
   </pluginRepositories>    
   <! This element describes all dependencies associated with the project. These dependencies form part of the project construction process. They are automatically downloaded from the repository defined by the project. For more information, see project dependency mechanisms. -->    
   <dependencies>    
    <! -- See dependencies/dependency element    
    <dependency>.</dependency>    
   </dependencies>    
   <! -- Disapproves of its use. Maven now ignores this element.    
   <reports/>       
   <! This element contains the specification for generating reports using the report plug-in. These reports are run when the user executes "MVN Site". You can see links to all reports in the navigation bar. See reporting element -->    
   <reporting>.</reporting>    
   <! See dependencyManagement element -->    
   <dependencyManagement>    
    <dependencies>    
     <! -- See dependencies/dependency element    
     <dependency>.</dependency>    
    </dependencies>    
   </dependencyManagement>    
   <! See distributionManagement element -->    
   <distributionManagement>.</distributionManagement>    
   <! -- See properties element -->    
   <properties/>    
  </profile>    
 </profiles>    
 <! Modules (sometimes called subprojects) are built as part of a project. Each module element listed is a relative path to the directory pointing to that module -->    
 <modules/>    
    <! Discover a list of remote repositories with dependencies and extensions. -->     
    <repositories>     
     <! -- Contains information needed to connect to the remote repository -->    
        <repository>    
         <! How to download a release from a remote repository    
         <releases>    
          <! --true or false indicates whether the repository is open for downloading certain types of artifacts (release, snapshot). -->    
    <enabled/>    
    <! This element specifies how often updates occur. Maven compares local POM timestamps with remote POM timestamps. The options are: always (always), daily (default, daily), interval: X (where X is a time interval in minutes), or never (never). -->    
    <updatePolicy/>    
    <! What to do when Maven validators fail to validate files: ignore, fail, or WARN. -->    
    <checksumPolicy/>    
   </releases>    
   <! How to handle the download of snapshot versions in remote repositories. With releases and snapshots, the POM can take different policies for each type of artifact in a separate repository. For example, someone might decide to turn on support for snapshot version downloads only for development purposes. See the repositories -- > / repository/releases elements    
   <snapshots>    
    <enabled/><updatePolicy/><checksumPolicy/>    
   </snapshots>    
   <! -- Unique identifier of the remote repository. Can be used to match the remote repository configured in settings. XML -->    
   <id>banseon-repository-proxy</id>     
   <! -- Remote repository name -->    
            <name>banseon-repository-proxy</name>     
            <! Protocol ://hostname/path -->    
            <url>http://192.168.1.169:9999/repository/</url>     
            <! Warehouse layout type used to locate and sort artifacts - can be default or Legacy. Maven 2 provides a default layout for its repository; However, Maven 1.x has a different layout. We can use this element to specify whether the layout is default or Legacy. -->    
            <layout>default</layout>               
        </repository>     
    </repositories>    
    <! Discover a list of remote repositories for plugins used for building and reporting    
    <pluginRepositories>    
     <! Contains the information you need to connect to the remote plug-in repository. See also repositories/repository element -->    
  <pluginRepository>.</pluginRepository>    
 </pluginRepositories>    
 
    <! This element describes all dependencies associated with the project. These dependencies form part of the project construction process. They are automatically downloaded from the repository defined by the project. For more information, see project dependency mechanisms. -->     
    <dependencies>     
        <dependency>    
   <! -- dependent group ID-->    
            <groupId>org.apache.maven</groupId>     
            <! -- Dependent artifact ID-->    
            <artifactId>maven-artifact</artifactId>     
            <! -- Version number of the dependency. In Maven 2, you can also configure a range of version numbers. -->    
            <version>3.8.1</version>     
            <! The default type is JAR. It usually represents the extension of the dependent file, but there are exceptions. A type can be mapped to another extension or classifier. Types often correspond to the packaging method used, although there are exceptions. Examples of some types: JAR, WAR, EJB-client, and test-jar. New types can be defined in plugin if extensions are set to true. So the previous type example is incomplete. -->    
            <type>jar</type>    
            <! -- Dependent classifiers. Classifiers can distinguish components that belong to the same POM but are built differently. The classifier name is appended to the version number of the file name. For example, if you want to build two separate JAR artifacts, one using the Java 1.4 compiler and the other using the Java 6 compiler, you can use the classifier to generate two separate JAR artifacts. -->    
            <classifier></classifier>    
            <! -- Dependent scope. During a project release, help determine which artifacts are included. Refer to dependency mechanisms for more information. -compile: default scope, used for compile. -provided: similar to compile, but supports what you would expect from the JDK or container, similar to classpath runtime: -test is required for execution: -system is used for test tasks: The corresponding elements need to be provided externally. Obtain the value from systemPath. - systemPath: Applies only to system. - optional: Indicates whether dependencies are passed when the project itself is dependent. For continuous dependencies -->     
            <scope>test</scope>       
            <! -- For system scope only. Note that use of this element is discouraged and may be overwritten in new versions. This element specifies the path on the file system for dependencies. You need an absolute path, not a relative path. It is recommended to use attributes to match absolute paths, such as ${java.home}. -->    
            <systemPath></systemPath>     
            <! From the list of dependencies, list the set of dependencies that are excluded when calculating transfer dependencies. This tells Maven that you only depend on the specified project, not the project's dependencies. This element is used to resolve version conflicts -->    
            <exclusions>    
             <exclusion>     
                    <artifactId>spring-core</artifactId>     
                    <groupId>org.springframework</groupId>     
                </exclusion>     
            </exclusions>       
            <! Optional dependencies. If you declare C dependencies as optional in project B, you need to explicitly reference C dependencies in projects that depend on B (e.g., project A). Optional dependencies block transitivity of dependencies. -->     
            <optional>true</optional>    
        </dependency>    
    </dependencies>    
    <! -- Disapproves of its use. Maven now ignores this element.    
    <reports></reports>    
    <! This element describes the specification for generating reports using the report plug-in. These reports are run when the user executes "MVN Site". You can see links to all reports in the navigation bar. -->    
 <reporting>    
  <! --true, the site does not include the default report. This includes reports from the Project Information menu. -->    
  <excludeDefaults/>    
  <! -- Where to store all generated reports. The default is ${project.build.directory}/site. -->    
  <outputDirectory/>    
  <! The reporting plug-ins used and their configuration. -->    
  <plugins>    
   <! The plugin element contains the information needed to describe the report plug-in -->    
   <plugin>    
    <! -- Group ID of the report plug-in in the repository -->    
    <groupId/>    
    <! Artifact ID for the report plug-in in the repository -->    
    <artifactId/>    
    <! -- The version (or version range) of the reporting plug-in being used -->    
    <version/>    
    <! Is any configuration propagated to subprojects?    
    <inherited/>    
    <! -- Report plug-in configuration -->    
    <configuration/>    
    <! Multiple specifications for a set of reports, each of which may have different configurations. One specification (report set) corresponds to one execution target. For example, there are 1,2,3,4,5,6,7,8,9 reports. 1,2,5 constitute report set A, corresponding to an execution target. 2,5,8 constitute report set B, corresponding to another execution target -->    
    <reportSets>    
     <! Represents a collection of reports and the configuration that generated the collection -->    
     <reportSet>    
      <! -- Unique identifier of the report collection, used for POM inheritance -->    
      <id/>    
      <! Configuration of the report used when generating the report set -->    
      <configuration/>    
      <! -- Whether the configuration is inherited to child POMs-->    
      <inherited/>    
      <! Which reports are used in this set?    
      <reports/>    
     </reportSet>    
    </reportSets>    
   </plugin>    
  </plugins>    
 </reporting>    
 <! Default dependency information inherited from all subprojects of the project. This part of the dependency information is not immediately resolved, but when a subproject declares a dependency (group ID and artifact ID information must be described), if some information other than the group ID and artifact ID is not described, The dependency here is matched by the Group ID and artifact ID, and the dependency information here is used. -->    
 <dependencyManagement>    
  <dependencies>    
   <! -- See dependencies/dependency element    
   <dependency>.</dependency>    
  </dependencies>    
 </dependencyManagement>       
    <! -- Project distribution information, indicating the location to be published after MVN deploy is executed. With this information, you can deploy web sites to remote servers or artifacts to remote repositories. -->     
    <distributionManagement>    
        <! -- Information needed to deploy project generated artifacts to remote repository -->    
        <repository>    
         <! Is a snapshot assigned a unique version number (with a timestamp and build sequence number)? Or do you use the same version number every time? See also repositories/repository element -->    
   <uniqueVersion/>    
   <id>banseon-maven2</id>     
   <name>banseon maven2</name>     
            <url>file://${basedir}/target/deploy</url>     
            <layout/>    
  </repository>    
  <! Where are the snapshots of the artifacts deployed? If there is no configuration the element, the default deployment to the repository element configuration of warehouses, see distributionManagement/repository elements -- -- >     
  <snapshotRepository>    
   <uniqueVersion/>    
   <id>banseon-maven2</id>    
            <name>Banseon-maven2 Snapshot Repository</name>    
            <url>scp://svn.baidu.com/banseon:/usr/local/maven-snapshot</url>     
   <layout/>    
  </snapshotRepository>    
  <! -- Information needed for the site to deploy the project -->     
        <site>    
         <! -- unique identifier of the deployment location, used to match the configuration in the site and settings.xml file -->     
            <id>banseon-site</id>     
            <! -- Name of deployment location -->    
            <name>business api website</name>     
            <! Protocol ://hostname/path -->    
            <url>     
                scp://svn.baidu.com/banseon:/var/www/localhost/banseon-web      
            </url>     
        </site>    
  <! -- URL of the project download page. If this element is not present, users should refer to the home page. The reason for using this element is to help locate artifacts that are not in the repository (due to license restrictions). -->    
  <downloadUrl/>    
  <! -- If the artifact has a new group ID and artifact ID (the artifact is moved to a new location), the relocation information for the artifact is listed here. -->    
  <relocation>    
   <! -- Component new group ID-->    
   <groupId/>    
   <! Artifact ID--> artifact ID    
   <artifactId/>    
   <! -- Component new version number -->    
   <version/>    
   <! Additional information about the move, such as the reason, to be displayed to the user. -->    
   <message/>    
  </relocation>    
  <! -- Gives the status of the component in the remote repository. You cannot set this element in your local project because it is automatically updated by the tool. Valid values are: None (default), converted (repository administrator from Maven 1 POM), partner (synchronized directly from partner 2 repository), Deployed (from Maven 2 instance office), verified (correct and final when verified). -->    
  <status/>           
    </distributionManagement>    
    <! Properties can be used throughout the POM or as a trigger condition (see description of activation element in settings.xml configuration file). The format is <name>value</name>. -->    
    <properties/>    
</project>    
Copy the code

This article:Blog.csdn.net/u010425776/…