从 GitHub 加载 Maven 依赖项 [英] Loading Maven dependencies from GitHub

查看:40
本文介绍了从 GitHub 加载 Maven 依赖项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将 Java 库从其 GitHub 存储库(该库使用 Maven 作为构建系统)添加为我的 Maven 项目的依赖项?我可以在不下载和编译库的情况下做到这一点吗?

How do I add a Java library from its GitHub repo (the library uses Maven as a build system) as a dependency to my Maven project? Can I do that without downloading and compiling the library?

推荐答案

现在您可以使用 JitPack 从 GitHub 存储库导入 Java 库.在你的 pom.xml 中:

Now you can import a Java library from a GitHub repo using JitPack. In your pom.xml:

  1. 添加仓库:

<repository>
    <id>jitpack.io</id>
    <url>https://jitpack.io</url>
</repository>

  1. 添加依赖

<dependency>
    <groupId>com.github.User</groupId>
    <artifactId>Repo name</artifactId>
    <version>Release tag</version>
</dependency>

它有效是因为 JitPack 会检查代码并构建它.所以你最终会下载 jar.
如果项目没有 GitHub 版本,则可以使用提交 ID 作为版本.

It works because JitPack will check out the code and build it. So you'll end up downloading the jar.
If the project doesn't have a GitHub release then its possible to use a commit id as the version.

这篇关于从 GitHub 加载 Maven 依赖项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆