java - 如何将 GitHub 存储库链接为 Maven 依赖项

标签 java maven github jitpack

我创建了一个 GitHub 存储库(私有(private)),并希望将其用作其他一些项目(私有(private))的 Maven 依赖项。因此,我在互联网上尝试了以下方法,但仍然可以导入其他项目的 Maven 依赖项。

我已经尝试过以下这些方法

  1. https://gist.github.com/fernandezpablo85/03cf8b0cd2e7d8527063 通过构建一个包含 jar 的分支并将分支 raw.githubusercontent.com 链接为 repo url。

  2. Hosting a Maven repository on github

  3. http://www.lordofthejars.com/2011/09/questa-di-marinella-e-la-storia-vera.html

  4. http://maven.apache.org/guides/mini/guide-3rd-party-jars-local.html (与步骤1相同)

  5. https://github.com/jitpack/maven-simple 我尝试与 JITPACK 链接并尝试过,但仍然不起作用。

这是基于引用文献 5,

在我的pom.xml文件中,我将要使用存储库的项目,我添加了如下依赖项,ant它能够更新maven索引并能够下载相关的pom CMD 的 .xml 文件。

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

   <dependency>
        <groupId>com.github.Amutheezan</groupId>
        <artifactId>CMD</artifactId>
        <version>v1.0ALPHA2</version>
    </dependency>

注意:-我的版本位置,我尝试过最近发布的版本,最新提交的值和 1.0-SNAPSHOT。

我仍然无法以任何一种方式导入。

import com.abc.CMD.*
or
import com.abc.*

可以帮我解决我犯错误的地方吗?

最佳答案

这是因为您的存储库是私有(private)的,并且您没有按照步骤授权jitpack访问私有(private)存储库。

https://jitpack.io/private

Private Repositories To use JitPack with private repositories:

Step 1. Authorize JitPack and get your personal access token:

Step 2. Add the token to $HOME/.m2/settings.xml as the username

<settings>
  <servers>
    <server>
      <id>jitpack.io</id>
      <username>AUTHENTICATION_TOKEN</username>
      <password>.</password>
    </server>
  </servers>
</settings>

The id of the server must be the same you use in your pom.xml

Step 3. (Optional) You may need to approve JitPack Application on GitHub

Build artifacts (jar, aar) are also private and you can only download them if you have access to the Git repo itself. See the documentation for more details

If you'd like to host JitPack inside your organization please see JitPack Enterprise

关于java - 如何将 GitHub 存储库链接为 Maven 依赖项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50691720/

相关文章:

java - 如何在传播结果或错误时调用 CompletableFuture 回调?

maven - 如何排除Gradle生成的POM文件中的依赖

c++ - 从 Maven 访问自定义(非 Java) Artifact 存储库

git - 上传文件到github的一个分支

java - 如何让我的程序根据用户输入打开一个窗口?

java - 为什么main方法应该是静态的

java - 附加变量进行 HTTP 调用时失败

java - Intellij 使用 Maven 输出目录

git 命令 - 推送时过滤提交

node.js - 列出git中master和当前分支之间的所有文件?如果有任何 Node 包可以将结果推送到数组 :) 中,那就太好了