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 Sonatype Nexus Repository 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 Sonatype Nexus, this means the Sonatype Nexus server asks you log in first before doing things like deploying artifacts. So when you get a 401 on deploying artifacts to Sonatype Nexus, you need to make sure you provide correct credentials.
Here is a check list you can follow:
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
sonatype-nexus-staging
Nexus Staging Repository
https://oss.sonatype.org/service/local/staging/deploy/maven2/
requires
<settings> ... <servers> <server> <id>sonatype-nexus-staging</id> <username>your-jira-id</username> <password>your-jira-pwd</password></server> </servers> ... </settings>