为什么 maven 会为当地的罐子打 repo.maven.apache.org



我在本地 maven 存储库中构建并安装了一个名为 com.example.project 的项目~/.m2。有时,并非总是如此,当我构建另一个依赖于com.example.project的项目时,maven 在调试消息中说:

Downloading: https://repo.maven.apache.org/maven2/com/example/project/maven-metadata.xml
为什么

maven 会查询该 URL,为什么偶尔会发生这种情况?首先,该 URL 上没有任何内容,其次,jar 已经存在于本地存储库中,第三,我没有更改本地 jar 依赖项的版本号。因此,假设我有 1000 个本地项目,它会查询 URL1、URL2、...、URL1000。此查询到不存在的 URL 的逻辑是什么?

为什么 maven 会查询该 URL,为什么偶尔会发生这种情况?

偶尔:是专门daily的,因为它是 maven 内置中央存储库的默认updatepolicy

如果你看一下所有pom文件继承的maven超级POM,你会发现存储库的配置如下

<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>

<release>元素未在此处显示,因此这意味着存储库将为其采用默认值。

已启用(默认值为 true

updatePolicy(默认值为 daily )-->个可能的值:"always"、"daily"(默认值)、"interval:XXX"(以分钟为单位)或"never"(仅当它在本地不存在时)。

希望这有帮助

最新更新