我正在尝试将 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