上传站点时出错:传输文件失败:<site-url> Return 代码为:401 ->

Error uploading site: Failed to transfer file: <site-url> Return code is: 401 ->

我无法部署由 maven-site-plugin 制作的站点。

我遇到了与这个问题类似的错误:Maven site deploy logs filling with [WARNING] Required credentials to nexus 3 但是里面有一条评论说这个问题是已知的,并在这里报告 https://issues.sonatype.org/browse/NEXUS-10112 但这个问题已经关闭了。

我按照教程 http://books.sonatype.com/nexus-book/reference/_creating_a_new_maven_project.html 一切正常,直到步骤 20.6 site:deploy。

我发现的唯一 "solution" 这个问题就在这里 https://benkiew.wordpress.com/2009/11/27/status-code-401-on-mvn-sitedeploy/ 但它不起作用。我的 settings.xml 和 pom.xml 匹配,所以这不是问题。

settings.xml 服务器 conf 如下所示:

   </servers>
    <server>        
      <id>nexus</id>        
      <username>XXXX</username>
      <password>XXXX</password>
    </server>
   </servers>

父pom.xml:

      <site>
          <id>nexus</id>
          <name>service-agents-repository</name>
          <url>dav:https://!URL!/repo/content/sites/agents</url>
      </site>

nexus 提供的id 与上面显示的两个不同,但我也尝试了那个id,我正在写这个问题所以没有用。 mvn site:deploy

输出的错误
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] Services: IoT agents
[INFO]
[INFO] Using the builder org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder with a thread count of 1
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Services: IoT agents 1.3.3-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-site-plugin:3.5.1:deploy (default-cli) @ parent ---
https://!URL!/repo/content/sites/agents/ - Session: Opened
[INFO] Pushing D:\!URL!\target\site
[INFO]    >>> to https://!URL!/repo/content/sites/agents/./
[WARNING] Required credentials not available for BASIC <any realm>@!URL!:443
[WARNING] Preemptive authentication requested but no default credentials available
[INFO] basic authentication scheme selected
[INFO] Failure authenticating with BASIC 'Sonatype Nexus Repository Manager'@!URL!:443
[WARNING] Required credentials not available for BASIC <any realm>@!URL!:443
[WARNING] Preemptive authentication requested but no default credentials available
[INFO] basic authentication scheme selected
[INFO] Failure authenticating with BASIC 'Sonatype Nexus Repository Manager'@!URL!:443
[WARNING] Required credentials not available for BASIC <any realm>@!URL!:443
[WARNING] Preemptive authentication requested but no default credentials available
[WARNING] Required credentials not available for BASIC <any realm>@!URL!:443
[WARNING] Preemptive authentication requested but no default credentials available
[INFO] basic authentication scheme selected
[INFO] Failure authenticating with BASIC 'Sonatype Nexus Repository Manager'@!URL!:443
 Transfer error: java.io.IOException: Unable to create collection: https://!URL!/repo/content/sites/agents/; status code = 401
Uploading: .//apidocs/allclasses-frame.html to https://!URL!/repo/content/sites/agents/

[WARNING] Required credentials not available for BASIC <any realm>@linksmart.eu:443
[WARNING] Preemptive authentication requested but no default credentials available
#########[INFO] basic authentication scheme selected
[INFO] Failure authenticating with BASIC 'Sonatype Nexus Repository Manager'@!URL!:443
https://!URL!/repo/content/sites/agents/./apidocs/allclasses-frame.html - Status code: 401
 Transfer error: org.apache.maven.wagon.TransferFailedException: Failed to transfer file: https://!URL!/repo/content/sites/agents/./apidocs/allclasses-frame.html. Return code is: 401
https://!URL!/repo/content/sites/agents/ - Session: Disconnecting
https://!URL!/repo/content/sites/agents/ - Session: Disconnected
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] Services: IoT agents ........................... FAILURE [  2.352 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.661 s
[INFO] Finished at: 2016-09-29T17:04:57+01:00
[INFO] Final Memory: 19M/219M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-site-plugin:3.5.1:deploy (default-cli) on project parent: Error uploading site: Failed to transfer file: https://!URL!/repo/content/sites/agents/./apidocs/allclasses-frame.html. Return code is: 401 -> [
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

如果需要更多信息,请询问。

谢谢。

您似乎已经遵循了 Nexus Repository Manager 2 的文档。您可以专门尝试 Nexus 3 的文档:http://books.sonatype.com/nexus-book/3.0/reference/raw.html#_configuring_maven_for_site_deployment

如果这没有帮助,请告诉我您的 Nexus 3 版本 运行,我们在 3.0.2 和 3.0.0 中对域名做了一些更改,虽然我没有认为这是问题所在。

抱歉这个问题。

发生错误。问题是 Maven 指向错误的 settings.xml 文件并且没有获得凭据。所以这里显示的配置是可以的。

谢谢。