如何使用 Maven Central 的 Google 镜像作为直接 link 下载 artifact/jar?
How to use Google mirror for Maven Central as a direct link to download an artifact/jar?
我正在使用 shell 脚本使用直接链接(例如 - this link)从 Maven 中央存储库下载许多 jar 文件。我在几个来源上读到 Google 托管所有 Maven Central 工件的公开可用副本,使用它代替 Maven Central 可以显着加快下载速度。
然而,为了实现这一点,我只能找到使用 Google 镜像的 Maven settings.xml 参考资料(如下所示):
<settings>
<mirrors>
<mirror>
<id>google-maven-central</id>
<name>GCS Maven Central mirror Asia Pacific</name>
<url>https://maven-central-asia.storage-download.googleapis.com/maven2/</url>
<mirrorOf>central</mirrorOf>
</mirror>
</mirrors>
</settings>
但这并不能解决我的目的。我正在寻找用于 shell 脚本而不是 Maven 项目的直接下载链接。怎么做?
我找到了问题的答案。很简单,你只需要将 artifact/jar 从 maven central 到 google 镜像的完整 URL 中的主机替换。 URL 的结构如下:
<HOST><Path to artifact>
主机可以采用 maven 中央存储库主机或 maven 存储库的任何镜像的值。
示例:
- 如果从 Maven Central 下载,请使用:
- 如果从亚太地区下载 Google Maven Central 镜像,使用:
- 如果从欧盟地区下载 Google Maven Central 镜像,使用:
- 如果从美洲地区下载 Google Maven Central 镜像,使用:
我正在使用 shell 脚本使用直接链接(例如 - this link)从 Maven 中央存储库下载许多 jar 文件。我在几个来源上读到 Google 托管所有 Maven Central 工件的公开可用副本,使用它代替 Maven Central 可以显着加快下载速度。
然而,为了实现这一点,我只能找到使用 Google 镜像的 Maven settings.xml 参考资料(如下所示):
<settings>
<mirrors>
<mirror>
<id>google-maven-central</id>
<name>GCS Maven Central mirror Asia Pacific</name>
<url>https://maven-central-asia.storage-download.googleapis.com/maven2/</url>
<mirrorOf>central</mirrorOf>
</mirror>
</mirrors>
</settings>
但这并不能解决我的目的。我正在寻找用于 shell 脚本而不是 Maven 项目的直接下载链接。怎么做?
我找到了问题的答案。很简单,你只需要将 artifact/jar 从 maven central 到 google 镜像的完整 URL 中的主机替换。 URL 的结构如下:
<HOST><Path to artifact>
主机可以采用 maven 中央存储库主机或 maven 存储库的任何镜像的值。
示例:
- 如果从 Maven Central 下载,请使用:
- 如果从亚太地区下载 Google Maven Central 镜像,使用:
- 如果从欧盟地区下载 Google Maven Central 镜像,使用:
- 如果从美洲地区下载 Google Maven Central 镜像,使用: