尝试将Maven build JAR部署到github软件包注册表时发生异常 [英] Exception while trying to deploy Maven build JAR to github package registry

查看:240
本文介绍了尝试将Maven build JAR部署到github软件包注册表时发生异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将Maven构建JAR部署到Github Package Registry.

I am trying to deploy the Maven build JAR to Github Package Registry.

执行mvn deploy命令时出现异常.

我正在使用一个简单的Maven项目,我想创建一个组件JAR并将其存储在Github Package Registry中.

I am using a simple Maven project which I want to create a component JAR and store in Github Package Registry.

构建成功,我现在想将此工件部署到注册表.

The build is successful I now want to deploy this artifact to registry.

我在~./m2/settings.xml中添加了以下内容.

I have added the below in ~./m2/settings.xml.

profilerepositories下添加了repository元素.

    <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中添加了以下内容:

Also, I have added the below in Maven project's 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软件包注册表中.

Expected: Deployment to be successful , build artifact is deployed to Github package registry.

实际: 异常如下:

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

有人可以帮助我解决问题.

Can someone help me in resolving the issue.

我已按照以下链接中提供的说明进行操作:

I have followed the instructions provided in the below link:

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替换为github username并将REPOSITORY替换带有项目存储库在github中的名称.

Inside your settings.xml file, <url>https://maven.pkg.github.com/OWNER/REPOSITORY</url> you need to make use that OWNER is replaced with your github username and REPOSITORY is replaced with the name of your project repository in github.

这篇关于尝试将Maven build JAR部署到github软件包注册表时发生异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆