gpt4 book ai didi

maven - Artifactory Maven 示例失败并显示 401 错误代码

转载 作者:行者123 更新时间:2023-12-02 03:23:03 25 4
gpt4 key购买 nike

我正在我的本地主机上尝试 Artifactory。尽管我已经关注了他们的 tutorial做他们的 Maven example ,我失败并显示 401 状态代码。这是我得到的错误:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project multi: Failed to deploy artifacts: Could not transfer artifact org.jfrog.test:multi:pom:3.7-20190117.083916-1 from/to snapshots (http://localhost:8081/artifactory/libs-snapshot-local): Failed to transfer file http://localhost:8081/artifactory/libs-snapshot-local/org/jfrog/test/multi/3.7-SNAPSHOT/multi-3.7-20190117.083916-1.pom with status code 401 -> [Help 1]

org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project multi: Failed to deploy artifacts: Could not transfer artifact org.jfrog.test:multi:pom:3.7-20190117.083916-1 from/to snapshots (http://localhost:8081/artifactory/libs-snapshot-local): Failed to transfer file http://localhost:8081/artifactory/libs-snapshot-local/org/jfrog/test/multi/3.7-SNAPSHOT/multi-3.7-20190117.083916-1.pom with status code 401

以下是位于/Users/my_user_name/.m2 中的 settings.xml 的内容:

<?xml version="1.0" encoding="UTF-8"?>
<settings xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.1.0 http://maven.apache.org/xsd/settings-1.1.0.xsd" xmlns="http://maven.apache.org/SETTINGS/1.1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<servers>
<server>
<username>${security.getCurrentUsername()}</username>
<password>${security.getEscapedEncryptedPassword()!"AP84FzVbdvwcgreF8m9HT77ESkA"}</password>
<id>central</id>
</server>
<server>
<username>${security.getCurrentUsername()}</username>
<password>${security.getEscapedEncryptedPassword()!"AP84FzVbdvwcgreF8m9HT77ESkA"}</password>
<id>snapshots</id>
</server>
</servers>
<profiles>
<profile>
<repositories>
<repository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>libs-release</name>
<url>http://localhost:8081/artifactory/libs-release</url>
</repository>
<repository>
<snapshots />
<id>snapshots</id>
<name>libs-snapshot</name>
<url>http://localhost:8081/artifactory/libs-snapshot</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>libs-release</name>
<url>http://localhost:8081/artifactory/libs-release</url>
</pluginRepository>
<pluginRepository>
<snapshots />
<id>snapshots</id>
<name>libs-snapshot</name>
<url>http://localhost:8081/artifactory/libs-snapshot</url>
</pluginRepository>
</pluginRepositories>
<id>artifactory</id>
</profile>
</profiles>
<activeProfiles>
<activeProfile>artifactory</activeProfile>
</activeProfiles>
</settings>

我已将其添加到 pom.xml

<distributionManagement>
<snapshotRepository>
<id>snapshots</id>
<name>0e5e20a55438-snapshots</name>
<url>http://localhost:8081/artifactory/libs-snapshot-local</url>
</snapshotRepository>
</distributionManagement>

错误代码 401 提示我存在身份验证问题。我想知道 settings.xml 如何解析凭据,例如${security.getCurrentUsername()}?我什至将纯用户名和密码放入 settings.xml 中,但仍然失败。

您能否告诉我我的设置出了什么问题以及如何解决此问题?

最佳答案

注意:有 a bug在artifactory 6.5.x 中,该问题已在版本6.5.2 中得到解决,该问题会阻止正确处理已过滤的资源。

${security.getCurrentUsername()}filtered resource 的用法,在 Artifactory 中,它允许将文本文件视为通过 FreeMarker 模板过滤的。

当您在 Artifactory UI 中下载 settings.xml 文件时,${security.[]} 字段将替换为您当前记录的用户名并进行加密密码(如果该错误不存在)。由于错误,或者如果您复制/粘贴文本内容而不是下载,则settings.xml将包含那些文字未替换的字符串,并且maven不会替换它们,因为它们不存在于maven中构建上下文。

如您链接的视频所示,您需要点击下载片段链接,而不是复制文本;否则,您可以复制/粘贴文本,然后需要在其中输入您的人工用户名和密码。

关于maven - Artifactory Maven 示例失败并显示 401 错误代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54232289/

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