gpt4 book ai didi

maven - 来自 GitHub 包注册表的 mvn 安装包

转载 作者:行者123 更新时间:2023-12-04 15:39:37 24 4
gpt4 key购买 nike

我已按照此 document 中给出的步骤进行操作在 GitHub 包注册表上部署包,我能够成功部署包。可以看出here .

现在我正在尝试将其作为依赖项安装到另一个项目中。如上面的链接所示,我在我的 pom 文件中添加了这个依赖项。

<dependency>
<groupId>com.github.ashishchopra/github_package_registry</groupId>
<artifactId>group-upload.artifct-upload</artifactId>
<version>0.0.1</version>
</dependency>

这显然会引发此错误:

[ERROR] 'dependencies.dependency.groupId' for com.github.ashishchopra/github_package_registry:group-upload.artifct-upload:jar with value 'com.github.ashishchopra/github_package_registry' does not match a valid id pattern.

现在我删除了 groupId 中 / 之前的部分,并像这样建立依赖关系:

<dependency>
<groupId>github_package_registry</groupId>
<artifactId>group-upload.artifct-upload</artifactId>
<version>0.0.1</version>
</dependency>

现在我收到这个错误:

Downloading: https://maven.pkg.github.com/ashishchopra/github_package_registry/group-upload.artifct-upload/0.0.1/group-upload.artifct-upload-0.0.1.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.275 s
[INFO] Finished at: 2019-10-10T19:47:42+05:30
[INFO] Final Memory: 18M/67M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project artifct-download: Could not resolve dependencies
for project group-download:artifct-download:jar:0.0.1-SNAPSHOT: Failed to collect dependencies at github_package_registry:group-upload.artifct-upload:jar:0.0.1: Failed to read artifact descriptor for github_package_registry:group-upload.artifct-upload:jar:0.0.1: Could not transfer artifact github_package_registry:group-upload.artifct-upload:pom:0.0.1 from/to github (https://maven.pkg.github.com/ashishchopra): Failed to transfer file: https://maven.pkg.github.com/ashishchopra/github_package_registry/group-upload.artifct-upload/0.0.1/group-upload.artifct-upload-0.0.1.pom. Return code is: 400 , ReasonPhrase:Bad Request. -> [Help 1]

我还尝试从依赖项中的 artifactId 中删除 groupId. 部分,并使其像这样:

<dependency>
<groupId>github_package_registry</groupId>
<artifactId>artifct-upload</artifactId>
<version>0.0.1</version>
</dependency>

这次我遇到了这个错误:

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 6.417 s
[INFO] Finished at: 2019-10-10T19:52:08+05:30
[INFO] Final Memory: 18M/67M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project artifct-download: Could not resolve dependencies for project group-download:artifct-download:jar:0.0.1-SNAPSHOT: Could not find artifact github_package_registry:artifct-upload:jar:0.0.1 in central (https://repo1.maven.org/maven2) ->
[Help 1]

所以没有组合,它似乎有效。

我的 ~/.m2/settings.yml 文件的内容:

<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
http://maven.apache.org/xsd/settings-1.0.0.xsd">

<activeProfiles>
<activeProfile>github</activeProfile>
</activeProfiles>



<profiles>
<profile>
<id>github</id>
<repositories>
<repository>
<id>central</id>
<url>https://repo1.maven.org/maven2</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</repository>
<repository>
<id>github</id>
<name>GitHub ashishchopra Apache Maven Packages</name>
<url>https://maven.pkg.github.com/ashishchopra</url>
</repository>
</repositories>
</profile>
</profiles>

<servers>
<server>
<id>github</id>
<username>ashishchopra</username>
<password>XXXX</password>
</server>
</servers>

这些是他们文档中的直接步骤,没什么特别的,但我还是无法让它工作。

实际的 pom 和 jar 文件存在于此链接中

https://maven.pkg.github.com/ashishchopra/github_package_registry/group-upload.artifct-upload/0.0.1/artifct-upload-0.0.1.pom

https://maven.pkg.github.com/ashishchopra/github_package_registry/group-upload.artifct-upload/0.0.1/artifct-upload-0.0.1.jar

最佳答案

根据 documentation您指出,maven 存储库的 URL 应包含您的 GitHub 存储库的名称,即 github_package_registry。这就是您在 settings.xml 中需要的内容:

<repositories>
<repository>
<id>central</id>
<url>https://repo1.maven.org/maven2</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>false</enabled></snapshots>
</repository>
<repository>
<id>github</id>
<url>https://maven.pkg.github.com/ashishchopra/github_package_registry</url>
</repository>
</repositories>

在你的 pom.xml 中,只需使用你的 GitHub Packages page 中描述的依赖项:

<dependency>
<groupId>group-upload</groupId>
<artifactId>artifct-upload</artifactId>
<version>0.0.1</version>
</dependency>

关于maven - 来自 GitHub 包注册表的 mvn 安装包,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58325279/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com