maven远程仓库访问顺序

首先需要了解一下各个配置文件,主要分为三类:

  1. 全局配置文件(${maven.home}/conf/settings.xml),maven安装路径下的/conf/settings.xml
  2. 用户配置文件(%USER_HOME%/.m2/settings.xml),windows用户文件夹下
  3. 项目配置文件:pom.xml

原文地址:What are the different types of profile? Where is each defined?

以上是mave下载依赖的大概过程,先会从本地仓库(${user.home}/.m2/repository 默认本地仓库)找,本地没有就会去远程仓库(https://repo.maven.apache.org/maven2/默认远程仓库)找。

仓库顺序原文地址:Profile Order

可能有些人不知道Parent POM和Super POM是什么意思,这里解释一下。

Parent POM:当前项目的父项目的pom文件

Super POM:顶级父pom,maven已经定义好的,就像java中所有类继承的Object一样,可能版本不一样有所不同。

以下是3.6.3的Super POM:

xml 复制代码
<project>
  <modelVersion>4.0.0</modelVersion>
 
  <repositories>
    <repository>
      <id>central</id>
      <name>Central Repository</name>
      <url>https://repo.maven.apache.org/maven2</url>
      <layout>default</layout>
      <snapshots>
        <enabled>false</enabled>
      </snapshots>
    </repository>
  </repositories>
 
  <pluginRepositories>
    <pluginRepository>
      <id>central</id>
      <name>Central Repository</name>
      <url>https://repo.maven.apache.org/maven2</url>
      <layout>default</layout>
      <snapshots>
        <enabled>false</enabled>
      </snapshots>
      <releases>
        <updatePolicy>never</updatePolicy>
      </releases>
    </pluginRepository>
  </pluginRepositories>
 
  <build>
    <directory>${project.basedir}/target</directory>
    <outputDirectory>${project.build.directory}/classes</outputDirectory>
    <finalName>${project.artifactId}-${project.version}</finalName>
    <testOutputDirectory>${project.build.directory}/test-classes</testOutputDirectory>
    <sourceDirectory>${project.basedir}/src/main/java</sourceDirectory>
    <scriptSourceDirectory>${project.basedir}/src/main/scripts</scriptSourceDirectory>
    <testSourceDirectory>${project.basedir}/src/test/java</testSourceDirectory>
    <resources>
      <resource>
        <directory>${project.basedir}/src/main/resources</directory>
      </resource>
    </resources>
    <testResources>
      <testResource>
        <directory>${project.basedir}/src/test/resources</directory>
      </testResource>
    </testResources>
    <pluginManagement>
      <!-- NOTE: These plugins will be removed from future versions of the super POM -->
      <!-- They are kept for the moment as they are very unlikely to conflict with lifecycle mappings (MNG-4453) -->
      <plugins>
        <plugin>
          <artifactId>maven-antrun-plugin</artifactId>
          <version>1.3</version>
        </plugin>
        <plugin>
          <artifactId>maven-assembly-plugin</artifactId>
          <version>2.2-beta-5</version>
        </plugin>
        <plugin>
          <artifactId>maven-dependency-plugin</artifactId>
          <version>2.8</version>
        </plugin>
        <plugin>
          <artifactId>maven-release-plugin</artifactId>
          <version>2.5.3</version>
        </plugin>
      </plugins>
    </pluginManagement>
  </build>
 
  <reporting>
    <outputDirectory>${project.build.directory}/site</outputDirectory>
  </reporting>
 
  <profiles>
    <!-- NOTE: The release profile will be removed from future versions of the super POM -->
    <profile>
      <id>release-profile</id>
 
      <activation>
        <property>
          <name>performRelease</name>
          <value>true</value>
        </property>
      </activation>
 
      <build>
        <plugins>
          <plugin>
            <inherited>true</inherited>
            <artifactId>maven-source-plugin</artifactId>
            <executions>
              <execution>
                <id>attach-sources</id>
                <goals>
                  <goal>jar-no-fork</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <inherited>true</inherited>
            <artifactId>maven-javadoc-plugin</artifactId>
            <executions>
              <execution>
                <id>attach-javadocs</id>
                <goals>
                  <goal>jar</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <inherited>true</inherited>
            <artifactId>maven-deploy-plugin</artifactId>
            <configuration>
              <updateReleaseInfo>true</updateReleaseInfo>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>
 
</project>
相关推荐
刃神太酷啦4 分钟前
C++ 容器适配器与核心数据结构精解:栈、队列、deque 底层实现与实战应用----《Hello C++ Wrold!》(17)--(C/C++)
java·c语言·数据结构·c++·qt·算法·leetcode
Resean022341 分钟前
SpringMVC 6+源码分析(三)DispatcherServlet实例化流程 2--(url 与contrller类如何进行映射)
java·spring boot·spring
菜菜的后端私房菜43 分钟前
Protocol Buffers!高效数据通信协议
java·后端·protobuf
w_t_y_y1 小时前
prometheus应用Counter&&Gauge
java
木子欢儿1 小时前
在 Debian 12 上安装 Xfce 桌面
java·linux·运维·服务器·debian
Vdeilae1 小时前
debian 时间同步 设置ntp服务端 客户端
java·服务器·debian
Seven971 小时前
剑指offer-18、⼆叉树的镜像
java
MacroZheng2 小时前
狂揽9.3k star!号称终端版Postman项目,太炫酷了!
java·spring boot·后端
XingYuyu_Coder2 小时前
(JAVA)自建应用调用企业微信API接口,设置企业可信IP
java·tcp/ip·企业微信
慕y2742 小时前
Java学习第一百零一部分——网关(Gateway)
java·网络·学习