1

I have configured nexus Remote Repository as central Repository. My settings.xml looks like below

    <mirror>
      <id>nexus</id>
      <name>central</name>
      <url>http://10.220.110.10:8081/repository/halosys-group/</url>
      <mirrorOf>*</mirrorOf>
    </mirror>
  </mirrors>

The problem now when i ran mvn package i am getting error like below.

Caused by: org.apache.maven.wagon.authorization.AuthorizationException: Authentication failed for http://10.220.110.10:8081/repository/halosys-group/org/apache/maven/plugins/maven-resources-plugin/2.5/maven-resources-plugin-2.5.pom 401 Unauthorized

Please let me know how to fix this issue

iamarunk
  • 109
  • 2
  • 16

1 Answers1

1

401 Unauthorized in that context with Nexus means that your request failed to authenticate with the Nexus server.

The fix depends on whether this is an issue with your username/password as entered, or a problem with not having the user/pass in your settings.xml at all. In either case, the following should fix your issue.

Ensure you have a <servers> section in your settings.xml with a server defined that has an id matching your mirror id (in this case, "nexus"). It should look something like this in your settings.xml:

  <servers>
    <server>
      <username>yourNexusUsername</username>
      <password>yourNexusPassword</password>
      <id>nexus</id>
    </server>
  </servers>

For reference: - http://maven.apache.org/ref/3.6.3/maven-settings/settings.html

Also note that you can encrypt your password, but that's beyond the scope of this answer.

Byron Lagrone
  • 911
  • 1
  • 7
  • 15
  • The error was do to encrypted password in settings.xml file. When i keep **password as plain text my mvn package command working fine**. Please let me know how to make it work with encrypted password – iamarunk Apr 29 '20 at 14:25
  • I would ordinarily suggest following a [tutorial like this one](https://www.roytuts.com/encrypt-user-passwords-in-maven-settings/) that shows how to create your master encryption password which you put into a `settings-security.xml` file; then, you run `mvn --encrypt-password [your-nexus-password]`, and replace your settings.xml password with that result. – Byron Lagrone May 03 '20 at 14:03