what-to-do-when-nexus-returns-401

3 篇文章 0 订阅

Sonatype helps open source projects by providing free Maven repository hosting and Maven central repository sync. There are hundreds of projects using this great service. As a result, I’ve received many questions from users, and a large amount of them is about ’401′. It is sometimes the case that when people try to deploy artifacts into Nexus using Maven, the deployment fails and they receive a 401 error.

The general definition of ’401′ can be bound at the HTTP RFC.  Briefly speaking, a ’401′ error occurs when the server asks for user authentication but the client can not provide it.  In Nexus, this means the Nexus server asks you log in first before doing things like deploying artifacts. So when you get a 401 on deploying artifacts to Nexus, you need to make sure you provide correct credentials.

Here is a check list you can follow:

  • Make sure your username/password is correct by logging into the Nexus UI. If curl is installed on your machine, you can try deploying an artifact with a command like this:
curl -u juven-test:****** https://oss.sonatype.org/service/local/staging/deploy/maven2/com/
juvenxu/ossrh-test/1.1/ossrh-test-1.1.pom --request PUT --data @pom.xml
  • If there is no error output, ensure your user privileges are correctly configured on the server.  Make sure to drop the repo you just created.
  • Make sure you have configured a server in settings.xml and that the server id is identical to the distribution repository id in pom.xml. For example, this:
  • <project>
      ...
      <distributionManagement>
        <repository>
          <id>sonatype-nexus-staging</id>
          <name>Nexus Staging Repository</name>
          <url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
        </repository>
      </distributionManagement>
      ...
    </project>
    
    requires
<settings>
  ...
  <servers>
    <server>
      <id>sonatype-nexus-staging</id>
      <username>your-jira-id</username>
      <password>your-jira-pwd</password>
    </server>
  </servers>
  ...
</settings>
  • Make sure your settings.xml is in the correct place (normally it’s _~/.m2/settings.xml).  You can check this by running mvn help:effective-settings.
  • If the server is using https but the URL in your POM is http, you might get 401 as well.
  • Use the latest version of Maven, as there is a known issue regarding 401: MNG-4469

转自:http://www.sonatype.com/people/2010/11/what-to-do-when-nexus-returns-401/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值