• maven pom.xml文件结构 以及 repository 优先级概述


    1. pom.xml 节点介绍

    参考 https://maven.apache.org/pom.html#Inheritance

    <project>  
    <modelVersion>4.0.0</modelVersion>  
    <!-- The Basics 项目的基本信息 -->  
    <groupId>...</groupId>  
    <artifactId>...</artifactId>  
    <version>...</version>  
    <packaging>...</packaging>  
    <dependencies>...</dependencies>  
    <parent>...</parent>  
    <dependencyManagement>...</dependencyManagement>  
    <modules>...</modules>  
    <properties>...</properties>  
    <!-- Build Settings 项目的编译设置 -->  
    <build>...</build>  
    <reporting>...</reporting>  
    <!-- More Project Information 其它项目信息 -->  
    <name>...</name>  
    <description>...</description>  
    <url>...</url>  
    <inceptionYear>...</inceptionYear>  
    <licenses>...</licenses>  
    <organization>...</organization>  
    <developers>...</developers>  
    <contributors>...</contributors>  
    <!-- Environment Settings -->  
    <issueManagement>...</issueManagement>  
    <ciManagement>...</ciManagement>  
    <mailingLists>...</mailingLists>   
    <scm>...</scm>  
    <prerequisites>...</prerequisites>  
    <repositories>...</repositories>  
    <pluginRepositories>...</pluginRepositories>  
    <distributionManagement>...</distributionManagement>
    <!-- 预定义模板 -->
    <profiles>
        <profile>
          <id>test</id>
          <activation>...</activation>
          <build>...</build>
          <modules>...</modules>
          <repositories>...</repositories>
          <pluginRepositories>...</pluginRepositories>
          <dependencies>...</dependencies>
          <reporting>...</reporting>
          <dependencyManagement>...</dependencyManagement>
          <distributionManagement>...</distributionManagement>
        </profile>
      </profiles> 
    </project>  
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49

    2. repository 优先级

    Repository Order
    Remote repository URLs are queried in the following order for artifacts until one returns a valid result:

    1. effective settings:
      A. Global settings.xml
      B.User settings.xml
    2. local effective build POM:
      A. Local pom.xml
      B. Parent POMs, recursively
      C. Super POM
    3. effective POMs from dependency path to the artifact.

    For each of these locations, the repositories within the profiles are queried first in the order outlined at Introduction to build profiles.
    Before downloading from a repository, mirrors configuration is applied.
    Effective settings and local build POM, with profile taken into account, can easily be reviewed to see their repositories order with mvn help:effective-settings and mvn help:effective-pom -Dverbose.
    以上部分 引用自官方说明 https://maven.apache.org/guides/introduction/introduction-to-profiles.html

    制品(artifacts)的url按照以下顺序查找配置文件,直到找到一个有效的仓库
    仓库有效顺序

    1. seting.xml
      1. 全局 setting.xml (${maven.home}/conf/settings.xml).
      2. 用户 setting.xml (%USER_HOME%/.m2/settings.xml).
    2. 影响构建的本地pom
      1. 当前项目的pom.xml
      2. 父的pom.xml,递归查找
      3. root pom.xml
    3. 从依赖路径到制品的有效pom

    对于上面的位置,先查找可用的profile
    在下载制品仓库之前,会先应用镜像配置与仓库
    可用通过 mvn help:effective-settingsmvn help:effective-pom -Dverbose 查看有效配置和完整pom

    # 生成完整的pom文件
    # Effective POMs, after inheritance, interpolation, and profiles are applied:
    # 将影响当前pom的配置,通过继承,插值,配置文件(profile) 应用到当前pom文件
    mvn help:effective-pom -Dverbose
    
    • 1
    • 2
    • 3
    • 4
  • 相关阅读:
    【华为上机真题 2022】| 差点没过
    第7章 - 多无人机系统的协同控制 --> 多无人机协同控制
    手刻 Deep Learning -第壹章 -PyTorch教学-激励函数与感知机入门(上)
    ubuntu 22.04 安装python-pcl
    数据结构--第七天
    将物流信息查询出来并选中某个快递公司标记颜色
    Java学习笔记4.4.1 包装类 - 基本类型与包装类相互转换
    抗疫众志成城网页设计成品 抗击疫情感动人物网页制作模板 大学生抗疫静态HTML网页源码 dreamweaver网页作业致敬逆行者网页设计作品
    前端学习-平面转换
    python selenium如何带cookie访问网站
  • 原文地址:https://blog.csdn.net/qq_22783587/article/details/120612001