java - 尝试将 Maven 构建 JAR 部署到 github 包注册表时出现异常
问题描述
我正在尝试将 Maven 构建 JAR 部署到 Github 包注册表。
mvn deploy
执行命令时出现异常。
我正在使用一个简单的 Maven 项目,我想创建一个组件 JAR 并存储在 Github 包注册表中。
构建成功我现在想将此工件部署到注册表。
我在~./m2/settings.xml
.
在in下添加了一个repository
元素。repositories
profile
<repository>
<id>github</id>
<name>GitHub OWNER Apache Maven Packages</name>
<url>https://maven.pkg.github.com/swastikaa-in</url>
</repository>
<servers>
<server>
<id>github</id>
<username>swastikaa</username>
<password>my personal token from github</password>
</server>
</servers>
另外,我在 Maven 项目中添加了以下内容pom.xml
:
<distributionManagement>
<repository>
<id>github</id>
<name>GitHub OWNER Apache Maven Packages</name>
<url>https://maven.pkg.github.com/swastikaa-in/math</url>
</repository>
</distributionManagement>
预期:部署成功,构建工件被部署到 Github 包注册表。
实际:例外情况如下:
Caused by: org.eclipse.aether.transfer.MetadataTransferException:
Could not transfer metadata com.redjohn.tools:math:0.0.2-SNAPSHOT/maven-metadata.xml
from/to github (https://maven.pkg.github.com/swastikaa-in/math):
Failed to transfer file https://maven.pkg.github.com/swastikaa-in/math/com/redjohn/tools/math/0.0.2-SNAPSHOT/maven-metadata.xml
with status code 400
Caused by: org.apache.maven.wagon.TransferFailedException:
Failed to transfer file https://maven.pkg.github.com/swastikaa-in/math/com/redjohn/tools/math/0.0.2-SNAPSHOT/maven-metadata.xml
with status code 400
有人可以帮我解决这个问题。
我已按照以下链接中提供的说明进行操作:
https://help.github.com/en/articles/configuring-apache-maven-for-use-with-github-package-registry
解决方案
在您的settings.xml
文件中,<url>https://maven.pkg.github.com/OWNER/REPOSITORY</url>
您需要使用OWNER
替换为您的 githubusername
并REPOSITORY
替换为您在 github 中的项目存储库的名称。
推荐阅读
- windows - 通过 Add-PrinterPort PowerShell 命令添加 IPP 端口?
- c - Prints out the number of multiples of 11 that are greater than or equal to N1 and less than or equal to N2
- javascript - MomentJS - utcOffset() 不应用偏移量?
- python-3.x - 如何按百分比增加图形的大小但保持原始纵横比?
- ms-access - 基于文本框隐藏/取消隐藏组合框
- javascript - 映射一个由五个圆圈组成的数组,并突出显示正在映射的当前元素
- python - Django 中的 ModelNotFoundError
- flutter - 从计算机(macos)上传图像或 svg 以用于 Flutter Web
- javascript - 使用 JQuery 显示和隐藏文章元素
- scala - Spark scala 模拟 spark.implicits 用于单元测试