Help us understand the problem. What is going on with this article?

Nexus repository manager に mvn deploy したら Return code is: 401, ReasonPhrase: Unauthorized.

経緯

別サーバにたてている Nexus Repository Managerpom.xml をデプロイしようとしたら Return code is: 401, ReasonPhrase: Unauthorized. が発生して BUILD FAILURE になった。

C:\xxx>mvn deploy
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building xxx x.x.x-SNAPSHOT
[INFO] ------------------------------------------------------------------------

...

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 5.540 s
[INFO] Finished at: 2019-09-18T10:47:41+09:00
[INFO] Final Memory: 11M/245M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project xxx: Failed to deploy artifacts: Could not transfer artifact xxx from/to xxx-snapshot (http://xx.xx.xx.xx/nexus/repository/snapshot/): Failed to transfer file: http://xx.xx.xx.xx/nexus/repository/snapshot/xxx. Return code is: 401, ReasonPhrase: Unauthorized. -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

解決方法

C:\Users\{your-username}\.m2\settings.xml にデプロイ先のサーバ情報が記述されていなかったので、追加することで解決。

pom.xml
  <distributionManagement>
    <snapshotRepository>
      <id>xxx-snapshot</id>
      <name>Snapshots</name>
      <url>http://xxx/nexus/repository/snapshot/</url>
    </snapshotRepository>
  </distributionManagement>

settings.xml
<settings>
    <servers>
        <server>
            <id>xxx-snapshot</id>
            <username>xxx</username>
            <password>xxx</password>
        </server>
    </servers>
</settings>
Why do not you register as a user and use Qiita more conveniently?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away