从GitHub加载Maven依赖项 [英] Loading Maven dependencies from GitHub
问题描述
如何从其GitHub repo(该库使用Maven作为构建系统)添加Java库作为我的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?
推荐答案
现在可以使用从GitHub repo导入Java库HREF = https://jitpack.io> JitPack 。
在您的pom.xml中:
Now you can import a Java library from a GitHub repo using JitPack. In your pom.xml:
- 添加存储库:
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
- 添加依赖关系
<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屋!