gpt4 book ai didi

尝试访问 Nexus 私有(private)存储库时,maven 收到 "Not Authorized"

转载 作者:行者123 更新时间:2023-12-03 04:22:10 24 4
gpt4 key购买 nike

我已经在 EC2 实例上设置了一个私有(private) Nexus 存储库管理器,并按照互联网上流传的有关如何设置 Maven 项目来使用它的各种说明进行操作。我还禁用了匿名帐户。 我可以通过 curl -U username:password <the_url> 连接和复制存储库 它似乎工作得很好。然而,当我尝试使用 Maven(任何目标)时,我得到的第一件事是

    [WARNING] Could not transfer metadata org.apache.maven.plugins:maven-compiler-plugin/maven-metadata.xml from/to nexus (http://MY_NEXUS_HOST:8081/nexus/content/groups/public): Not authorized , ReasonPhrase:Unauthorized.

然后 mvn 命令失败,因为它无法在任何地方找到该插件。因此,我可以使用rest命令并且它按预期工作,但不是通过maven,这一事实向我表明这是配置问题。我想我很清楚发生了什么,并且我已经检查并重新检查了文件,但我没有发现任何问题。 这是settings.xml 文件

<servers>
<server>
<id>nexus-snapshot</id>
<username>USER_NAME</username>
<password>USER_PASSWD</password>
</server>
<server>
<id>nexus-release</id>
<username>USER_NAME</username>
<password>USER_PASSWD</password>
</server>

</servers>
<mirrors>
<mirror>
<!--This sends everything else to /public -->
<id>nexus</id>
<mirrorOf>*</mirrorOf>
<url>http://MY_NEXUS_HOST:8081/nexus/content/groups/public</url>
</mirror>
</mirrors>
<profiles>
<profile>
<id>nexus</id>
<!--Enable snapshots for the built in central repo to direct -->
<!--all requests to nexus via the mirror -->
<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>
<updatePolicy>never</updatePolicy>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
<activeProfiles>
<!--make the profile active all the time -->
<activeProfile>nexus</activeProfile>
</activeProfiles>

这是 pom 文件的相关部分

    <distributionManagement>
<repository>
<id>nexus-release</id>
<name>Nexus Release Repository</name>
<url>http://MY_NEXUS_HOST:8081/nexus/content/repositories/releases</url>
</repository>
<snapshotRepository>
<id>nexus-snapshot</id>
<name>Nexus Snapshot Repository</name>
<url>http://MY_NEXUS_HOST:8081/nexus/content/repositories/snapshots</url>
</snapshotRepository>
</distributionManagement>

我想知道是否有办法查看我遇到的确切问题。例如,如果我收到 401、403 或(出于某种原因?)404。如果有人可以帮助我,我将非常感激。哦,maven 和 Nexus 都是截至上周的最新版本。*编辑是因为无论您在点击提交之前检查了多少次...

最佳答案

哦,我的时髦山羊。问题在于,显然在 settings.xml 中,Id 字段必须与服务器字段中的字段相同。即:

<servers>
<server>
<id>nexus-release</id> <---THIS MUST MATCH
<username>USER_NAME</username>
<password>USER_PASSWD</password>
</server>
</servers>
<mirrors>
<mirror>
<id>nexus-release</id> <---THIS
<mirrorOf>*</mirrorOf>
<url>http://MY_NEXUS_HOST:8081/nexus/content/groups/public</url>
</mirror>
</mirrors>

我想我使用哪一个并不重要(在这种情况下它们都是相同的,但这并不一定总是正确的)。

关于尝试访问 Nexus 私有(private)存储库时,maven 收到 "Not Authorized",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32569919/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com