【发布时间】:2020-02-16 19:19:27
【问题描述】:
我们必须使用 Nexus OSS 版本 3.20.1-01。当我们尝试将 Maven2 工件(jar)部署或推送到 Nexus 时,我们遇到了问题。我们使用了一个帐户 test123,密码为 test123。 test123 在 nexus 中有特权 nx-admin。如果我们尝试登录管理控制台,我们可以毫无问题地做到这一点。
但是如果我们尝试使用名称 sligro-proxy 引用在 Nexus 上配置的代理服务器,那么由于某种原因它会发送 401。
我们使用 Maven 3.5.4
但由于某些愚蠢的原因,我们不能使用代理 sligro-proxy 来 maven Central。如果我们通过删除 settings.xml 文件来使用没有 Nexus 的 Maven,那么这个构建就可以了。 ./mvn 包。
如果我更改了 settings.xml 文件中的某些内容,那么我会看到构建正在响应该更改。
我们在 Nexus 的 request.log 中看到 401 是这样的:
192.168.178.123 - - [16/Feb/2020:19:46:50 +0100] "HEAD /nexus/repository/sligro-proxy/org/apache/maven/plugins/maven-resources-plugin/2.6/maven-resources-plugin-2.6.pom HTTP/1.1" 401 - 0 2 "Apache-Maven/3.5.4 (Java 1.8.0_112; Linux 3.10.0-957.27.2.el7.x86_64)" [qtp1998317514-191]
在客户端我们看到: [INFO] 完成时间:2020-02-16T19:46:50+01:00 [信息] --------------------------------------------- ------------------------- [错误] 插件 org.apache.maven.plugins:maven-resources-plugin:2.6 或其依赖项之一无法解析:无法读取 org.apache.maven.plugins:maven-resources-plugin:jar 的工件描述符:2.6:无法将工件 org.apache.maven.plugins:maven-resources-plugin:pom:2.6 从/到nexus(http://192.168.178.178:8081/nexus/repository/sligro-proxy):未授权,ReasonPhrase:未授权。 -> [帮助 1] [错误] [错误] 要查看错误的完整堆栈跟踪,请使用 -e 开关重新运行 Maven。 [错误] 使用 -X 开关重新运行 Maven 以启用完整的调试日志记录。 [错误] [错误] 有关错误和可能的解决方案的更多信息,请阅读以下文章: [错误] [帮助 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginResolutionException
这是我的 settings.xml 文件:
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>nexus-proxy</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.10</version>
</dependency>
</dependencies>
<distributionManagement>
<repository>
<id>sligro</id>
<name>maven-releases</name>
<url>http://192.168.178.178:8081/nexus/repository/maven-releases/</url>
</repository>
<snapshotRepository>
<id>sligro</id>
<name>maven-snapshots</name>
<url>http://192.168.178.178:8081/nexus/repository/maven-snapshots/</url>
</snapshotRepository>
</distributionManagement>```
This is my settings.xml file:
</project>This is my settings file:<?xml version="1.0" encoding="UTF-8"?>
<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 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<proxies/>
<servers>
<server>
<id>nexus-snapshots</id>
<username>test123</username>
<password>test123</password>
</server>
<server>
<id>nexus-releases</id>
<username>test123</username>
<password>test123</password>
</server>
<server>
<id>sligro</id>
<username>test123</username>
<password>test123</password>
</server>
<server>
<id>sligro-proxy</id>
<username>test123</username>
<password>test123</password>
</server>
<server>
<id>/192.168.178.178:8081</id>
<username>test123</username>
<password>test123</password>
</server>
</servers>
<mirrors>
<mirror>
<id>nexus</id>
<mirrorOf>*</mirrorOf>
<url>http://192.168.178.178:8081/nexus/repository/sligro-proxy</url>
</mirror>
</mirrors>
<profiles>
<profile>
<id>sligro</id>
<repositories>
<repository>
<id>central</id>
<url>http://central</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<url>http://central</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
<properties>
<nexus.url>http://192.168.178.178:8081/nexus/repository</nexus.url>
</properties>
</profile>
</profiles>
<activeProfiles>
<activeProfile>sligro</activeProfile>
</activeProfiles>
</settings>
Well I almost spend to 2 days this weekend to find out what the problem is and
changed tons of params but it gives always the 401. Help would be appriciated.
Thanks
【问题讨论】: