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>
相关推荐
向哆哆15 分钟前
Spring Boot快速开发:从零开始搭建一个企业级应用
java·spring boot·后端
gs8014030 分钟前
检查当前 Docker 使用的 默认运行时(default runtime)方法
java·开发语言·eureka
hello_ejb333 分钟前
聊聊Spring AI autoconfigure模块的拆分
java·人工智能·spring
wolfengi1 小时前
Idea Code Templates配置
java·ide·intellij-idea
Arenaschi1 小时前
运用fmpeg写一个背英文单词的demo带翻译
java·笔记·tcp/ip·其他·eclipse·maven
一只蒟蒻ovo1 小时前
操作系统导论——第26章 并发:介绍
java·开发语言
老华带你飞1 小时前
音乐网站|基于SprinBoot+vue的音乐网站(源码+数据库+文档)
java·前端·数据库·vue.js·论文·毕设·音乐网站
熊文豪2 小时前
Java+Selenium+快代理实现高效爬虫
java·爬虫·selenium·隧道代理·快代理
purrrew2 小时前
【Java ee 初阶】多线程(8)
java·java-ee
TPBoreas5 小时前
Jenkins 改完端口号启动不起来了
java·开发语言