title: Getting Return code is: 401, ReasonPhrase: Unauthorized. while uploading a jar to nexus Repository
body: <p>Getting Unauthorized.  error while uploading artifacts to Nexus Repository.</p>
  
  <p>Please Help.......
  <strong><em>Full Error</em></strong> :</p>
  
  <p>Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.8.2:deploy (default-deploy) on project HelloWorldTest: Failed to deploy artifacts: Could not transfer artifact com.LMB:HelloWorldTest:jar:1.0-20190704.125442-1 from/to FirstDevOpsProj_SnapShot (<a href="http://localhost:8089/nexus/content/repositories/snapshots/" rel="nofollow noreferrer">http://localhost:8089/nexus/content/repositories/snapshots/</a>): Failed to transfer file: <a href="http://localhost:8089/nexus/content/repositories/snapshots/com/LMB/HelloWorldTest/1.0-SNAPSHOT/HelloWorldTest-1.0-20190704.125442-1.jar" rel="nofollow noreferrer">http://localhost:8089/nexus/content/repositories/snapshots/com/LMB/HelloWorldTest/1.0-SNAPSHOT/HelloWorldTest-1.0-20190704.125442-1.jar</a>. Return code is: 401, ReasonPhrase: Unauthorized. -> [Help 1]</p>
  
  <p>I tried with adding or removing (/) at the last of the Repository URL but didn't worked.</p>
  
  <p>Below are the <strong>Setting.xml</strong>, <strong>Pom.xml</strong> and <strong>Nexus Repository Summary</strong> details
  <a href="https://i.stack.imgur.com/3BSyZ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3BSyZ.png" alt="enter image description here"></a></p>
  
  <pre><code>
  &lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
                            https://maven.apache.org/xsd/settings-1.0.0.xsd"&gt;
  &lt;pluginGroups&gt;&lt;/pluginGroups&gt;
  &lt;proxies&gt;&lt;/proxies&gt;
  &lt;servers&gt;
     &lt;server&gt;
        &lt;id&gt;FirstDevOpsProj_SnapShot&lt;/id&gt;
        &lt;username&gt;admin&lt;/username&gt;
        &lt;password&gt;admin123&lt;/password&gt;
      &lt;/server&gt;
    &lt;/servers&gt;
  &lt;mirrors&gt;&lt;/mirrors&gt;
  
    &lt;profiles&gt;
      &lt;profile&gt;
      &lt;id&gt;nexus&lt;/id&gt;
      &lt;repositories&gt;
        &lt;repository&gt;
          &lt;id&gt;FirstDevOpsProj_SnapShot&lt;/id&gt;
          &lt;name&gt;FirstDevOpsProj_SnapShot&lt;/name&gt;
          &lt;releases&gt;
            &lt;enabled&gt;true&lt;/enabled&gt;
          &lt;/releases&gt;
          &lt;snapshots&gt;
            &lt;enabled&gt;true&lt;/enabled&gt;
          &lt;/snapshots&gt;
          &lt;url&gt;http://localhost:8089/nexus/content/repositories/snapshots/&lt;/url&gt;
        &lt;/repository&gt;
      &lt;/repositories&gt;
      &lt;/profile&gt;
    &lt;/profiles&gt;
  &lt;activeProfiles&gt;
      &lt;activeProfile&gt;nexus&lt;/activeProfile&gt;
    &lt;/activeProfiles&gt;
  &lt;/settings&gt;
  </code></pre>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  
  &lt;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"&gt;
    &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
  
    &lt;groupId&gt;com.LMB&lt;/groupId&gt;
    &lt;artifactId&gt;HelloWorldTest&lt;/artifactId&gt;
    &lt;version&gt;1.0-SNAPSHOT&lt;/version&gt;
    &lt;packaging&gt;jar&lt;/packaging&gt;
    &lt;name&gt;HelloWorldTest&lt;/name&gt;
    &lt;!-- FIXME change it to the project's website --&gt;
    &lt;url&gt;http://www.example.com&lt;/url&gt;
  
    &lt;properties&gt;
      &lt;project.build.sourceEncoding&gt;UTF-8&lt;/project.build.sourceEncoding&gt;
      &lt;maven.compiler.source&gt;1.7&lt;/maven.compiler.source&gt;
      &lt;maven.compiler.target&gt;1.7&lt;/maven.compiler.target&gt;
    &lt;/properties&gt;
  
    &lt;dependencies&gt;
      &lt;dependency&gt;
        &lt;groupId&gt;junit&lt;/groupId&gt;
        &lt;artifactId&gt;junit&lt;/artifactId&gt;
        &lt;version&gt;4.11&lt;/version&gt;
        &lt;scope&gt;test&lt;/scope&gt;
      &lt;/dependency&gt;
    &lt;/dependencies&gt;
    &lt;distributionManagement&gt;
      &lt;snapshotRepository&gt;
        &lt;id&gt;FirstDevOpsProj_SnapShot&lt;/id&gt;
        &lt;url&gt;http://localhost:8089/nexus/content/repositories/snapshots/&lt;/url&gt;
      &lt;/snapshotRepository&gt;
    &lt;/distributionManagement&gt;
    &lt;build&gt;
      &lt;pluginManagement&gt;&lt;!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) --&gt;
        &lt;plugins&gt;
          &lt;!-- clean lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle --&gt;
          &lt;plugin&gt;
            &lt;artifactId&gt;maven-clean-plugin&lt;/artifactId&gt;
            &lt;version&gt;3.1.0&lt;/version&gt;
          &lt;/plugin&gt;
          &lt;!-- default lifecycle, jar packaging: see https://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging --&gt;
          &lt;plugin&gt;
            &lt;artifactId&gt;maven-resources-plugin&lt;/artifactId&gt;
            &lt;version&gt;3.0.2&lt;/version&gt;
          &lt;/plugin&gt;
          &lt;plugin&gt;
            &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
            &lt;version&gt;3.8.0&lt;/version&gt;
          &lt;/plugin&gt;
          &lt;plugin&gt;
            &lt;artifactId&gt;maven-surefire-plugin&lt;/artifactId&gt;
            &lt;version&gt;2.22.1&lt;/version&gt;
          &lt;/plugin&gt;
          &lt;plugin&gt;
            &lt;artifactId&gt;maven-jar-plugin&lt;/artifactId&gt;
            &lt;version&gt;3.0.2&lt;/version&gt;
          &lt;/plugin&gt;
          &lt;plugin&gt;
            &lt;artifactId&gt;maven-install-plugin&lt;/artifactId&gt;
            &lt;version&gt;2.5.2&lt;/version&gt;
          &lt;/plugin&gt;
          &lt;plugin&gt;
            &lt;artifactId&gt;maven-deploy-plugin&lt;/artifactId&gt;
            &lt;version&gt;2.8.2&lt;/version&gt;
            &lt;executions&gt;
              &lt;execution&gt;
                &lt;id&gt;default-deploy&lt;/id&gt;
                &lt;phase&gt;deploy&lt;/phase&gt;
                &lt;goals&gt;
                  &lt;goal&gt;deploy&lt;/goal&gt;
                &lt;/goals&gt;
              &lt;/execution&gt;
            &lt;/executions&gt;
          &lt;/plugin&gt;
          &lt;!-- site lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#site_Lifecycle --&gt;
          &lt;plugin&gt;
            &lt;artifactId&gt;maven-site-plugin&lt;/artifactId&gt;
            &lt;version&gt;3.7.1&lt;/version&gt;
          &lt;/plugin&gt;
          &lt;plugin&gt;
            &lt;artifactId&gt;maven-project-info-reports-plugin&lt;/artifactId&gt;
            &lt;version&gt;3.0.0&lt;/version&gt;
          &lt;/plugin&gt;
        &lt;/plugins&gt;
      &lt;/pluginManagement&gt;
    &lt;/build&gt;
  &lt;/project&gt;
  </code></pre>
  
  <pre><code>
  Repository ID: snapshots
  Repository Name: Snapshots
  Repository Type: hosted
  Repository Policy: Snapshot
  Repository Format: maven2
  Contained in groups: 
     Public Repositories
  
  
  &lt;distributionManagement&gt;
    &lt;snapshotRepository&gt;
      &lt;id&gt;snapshots&lt;/id&gt;
      &lt;url&gt;http://localhost:8089/nexus/content/repositories/snapshots&lt;/url&gt;
    &lt;/snapshotRepository&gt;
  &lt;/distributionManagement&gt;
  </code></pre>