【问题标题】:why can't i upload artifact to archiva (Unauthorized), but i can download from it with admin user?为什么我不能将工件上传到档案(未经授权),但我可以使用管理员用户从它下载?
【发布时间】:2014-09-24 09:00:44
【问题描述】:

我在 archiva 工作了大约一年,

我通过 archiva GUI 手动上传我的 jar,它运行良好。

现在我想用 maven deploy 上传一个工件,问题是我得到 401-Unauthorized。 请记住:

1.) 我可以毫无问题地从这个存储库下载。

2.) 我使用管理员用户。

3.) 我可以手动上传这个用户。

这是我得到的日志:

[com:apinterface.parent] Downloading: http://xx.xx.xx.xx:9080/archiva/repository/snapshots/com/apinterface.parent/1.0-SNAPSHOT/maven-metadata.xml

[11:43:39][Step 1/3] [INFO] ------------------------------------------------------------------------
[11:43:39][Step 1/3] [ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project apinterface.parent: Failed to deploy artifacts: Could not transfer artifact com:apinterface.parent:pom:1.0-20140924.084338-1 from/to snapshots (http://xx.xx.xx.xx:9080/archiva/repository/snapshots): Failed to transfer file: http://xx.xx.xx.xx:9080/archiva/repository/snapshots/com/apinterface.parent/1.0-SNAPSHOT/apinterface.parent-1.0-20140924.084338-1.pom. Return code is: 401, ReasonPhrase: Unauthorized. -> [Help 1]

【问题讨论】:

    标签: maven repository archiva


    【解决方案1】:

    这应该是因为您尚未将 Maven 配置为在部署阶段使用 Archiva 用户名/密码来上传工件。

    我假设您已经在 pom 文件中配置了 distributionManagement 部分。

    <distributionManagement>
        <snapshotRepository>
            <id>snapshots</id>
            <name>Internal Snapshots</name>
            <url>http://xx.xx.xx.xx:9080/archiva/repository/snapshots/</url>
        </snapshotRepository>
        <repository>
            <id>releases</id>
            <name>Internal Releases</name>
            <url>http://xx.xx.xx.xx:9080/archiva/repository/releases</url>
        </repository>
    </distributionManagement>
    

    您的 Maven 设置文件中应该有具有匹配 id 的服务器(如下面的示例)来配置 maven 在上传(部署)工件时应该使用的用户名/密码

    <settings>
      <servers>
        <server>
          <id>snapshots</id>
          <username>archiva-user</username>
          <password>archiva-pwd</password>
        </server>
        <server>
          <id>releases</id>
          <username>archiva-user</username>
          <password>archiva-pwd</password>
        </server>
      </servers>
    </settings>
    

    【讨论】:

    • 在我的例子中,我将“archiva.snapshots”作为与档案管理页面中的存储库 ID 不同的 ID。它必须完全相同。
    【解决方案2】:

    或者,您可以通过添加 Guest 用户访问以下存储库的权限来免费下载:

    管理 -> 用户(选项卡)

    编辑角色并在“Repository Manager Repository Observer”中选择免费访问存储库

    【讨论】:

      猜你喜欢
      • 2018-06-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-07-19
      • 1970-01-01
      • 2011-09-13
      相关资源
      最近更新 更多