且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何以编程方式使用 maven 下载 jar

更新时间:2023-02-12 19:37:08

Option 1

khmarbaise 推荐的以太.

Option 1

Aether as recommended by khmarbaise.

它是 Maven 3.0 附带的原生库

It's the native library that ships with Maven 3.0

如果您想要一个从命令行或 shell 脚本下载 Maven 模块的简单解决方案,Apache ivy 有一个 独立 jar.

If you want a simple solution for downloading Maven modules from the command line or within a shell script, Apache ivy has a standalone jar.

示例:

以编程方式使用 IVY 依赖项管理器

如果您只是在寻找 Maven jar 并且不关心依赖项管理,那么它甚至更简单.

If you're just looking for a Maven jar and don't care about dependency management it's even simpler.

以下是直接从 Maven Central 检索 log4j jar 的方法:

Here's how to retrieve the log4j jar direct from Maven Central:

curl -O http://search.maven.org/remotecontent?filepath=log4j/log4j/1.2.17/log4j-1.2.17.jar

如果您使用 Nexus 存储库管理器,它有一个有用的 REST API

If you're using a Nexus repository manager it has a useful REST API

使用 Nexus rest API 获取给定 groupid/artifactId 的最新工件版本