3

我被添加为 Maven 项目的开发人员,现在我需要发布。我已经添加nexus-staging-maven-pluginpom.xml文件中。

<plugin>
  <groupId>org.sonatype.plugins</groupId>
  <artifactId>nexus-staging-maven-plugin</artifactId>
  <version>1.6.3</version>
  <extensions>true</extensions>
  <configuration>
    <serverId>ossrh</serverId>
    <nexusUrl>https://oss.sonatype.org/</nexusUrl>
    <autoReleaseAfterClose>true</autoReleaseAfterClose>
  </configuration>
</plugin>

我也添加distributionManagementpom.xml

<distributionManagement>
  <snapshotRepository>
    <id>ossrh</id>
    <url>https://oss.sonatype.org/content/repositories/snapshots</url>
  </snapshotRepository>
  <repository>
    <id>ossrh</id>
    <url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
  </repository>
</distributionManagement>

我已将凭据放入~/.m2/settings.xml

<settings>
  <servers>
    <server>
      <id>ossrh</id>
      <username>divanov-oss.sonatype.org-account</username>
      <password>divanov-oss.sonatype.org-password</password>
    </server>
  </servers>
</settings>

我还尝试在 oss.sonatype.org 上创建和使用“访问用户令牌”作为我的凭据。

现在我正在执行将发布部署到 Maven 中心。

mvn clean deploy

最终出现错误:

[ERROR] Failed to execute goal org.sonatype.plugins:nexus-staging-maven-plugin:1.6.3:deploy
(injected-nexus-deploy) on project project: Failed to deploy artifacts:
Could not transfer artifact
project:jar:4.4.0-20141228.104011-1 from/to ossrh
(https://oss.sonatype.org/content/repositories/snapshots): Access denied to:
https://oss.sonatype.org/content/repositories/snapshots/project/project/4.4.0-SNAPSHOT/project-4.4.0-20141228.104011-1.jar,
ReasonPhrase: Forbidden. -> [Help 1]

或者

[INFO] Performing remote staging...
[INFO] 
[INFO]  * Remote staging into staging profile ID "329a0bc2b7ce06"
[ERROR] Remote staging finished with a failure: 403 - Forbidden
[ERROR] 
[ERROR] Possible causes of 403 Forbidden:
[ERROR]  * you have no permissions to stage against profile with ID "329a0bc2b7ce06"? Get to Nexus admin...

如何在我尝试发布的 Maven 项目中检查我的访问权限?

4

2 回答 2

4

您的凭据可能很好,如果不是,您将收到 401 错误。你得到403(禁止)。这意味着凭据已被接受,但您无权发布工件。最常见的原因是您使用的 Maven 组 ID 与分配给您的组 ID 不同。在“社区支持 - 开源项目存储库托管”中的https://issues.sonatype.org提交问题,我们会解决这个问题。

于 2014-12-29T14:14:39.487 回答
-1

您需要使用的凭据不应该是 Sonatype JIRA,而是 oss.sonatype.org。您需要在那里单独注册。

[更新]问题已更改,因此此答案不再相关。我会保留它,因为这是一个常见的错误。

于 2014-12-28T11:07:47.097 回答