Search code examples
mavennexus

Deploying artifacts in nexus from maven gives error "Return code is: 401"?


I am getting 401 error while deploying in nexus. I does not make any changes to the installed nexus. Nexus is running on localhost:8080/nexus and i am able to login with default user/password. When i am running mvn deploy i am getting this error.

Here is my POM.

 <groupId>testproject</groupId>
 <artifactId>testproject</artifactId>
 <packaging>jar</packaging>
 <version>1.0-SNAPSHOT</version>
 <name>testproject</name>
 <url>http://maven.apache.org</url>
 <distributionManagement>
  <repository>
      <id>releases</id>
      <url>http://localhost:8080/nexus/content/repositories/releases</url>
    </repository>
    <snapshotRepository>
       <id>snapshots</id>
       <url>http://localhost:8080/nexus/content/repositories/snapshots</url>
    </snapshotRepository>
</distributionManagement>
<dependencies>
 .........
</dependencies>

and ~/.m2/settings.xml

<servers>
    <server>
        <id>snapshots</id>
        <username>deployment</username>
        <password>deployment123</password>
    </server>
    <server>
        <id>releases</id>
        <username>deployment</username>
        <password>deployment123</password>
    </server>
</servers>

Exception:

Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-           deploy) on project testproject: Failed to deploy artifacts: Could not transfer artifact testproject:testproject:jar:1.0-20131213.150615-1 from/to snapshots (http://localhost:8080/nexus/content/repositories/snapshots): Failed to transfer file: http://localhost:8080/nexus/content/repositories/snapshots/testproject/testproject/1.0-SNAPSHOT/testproject-1.0-20131213.150615-1.jar. 
Return code is: 401 -> [Help 1]

Please help me.


Solution

  • It's working now. Need to edit ${MVN_HOME}/conf/settings.xml instead of /home/{user}/.m2/settings.xml