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

Mah*_*hdi 1 artifactory maven maven-deploy-plugin

我正在我的本地主机上尝试 Artifactory。尽管我已经按照他们的教程 来做他们的 Maven 示例,但我还是失败了 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
Run Code Online (Sandbox Code Playgroud)

这是位于 /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>

Run Code Online (Sandbox Code Playgroud)

我已经将它添加到 pom.xml

<distributionManagement>
    <snapshotRepository>
        <id>snapshots</id>
        <name>0e5e20a55438-snapshots</name>
        <url>http://localhost:8081/artifactory/libs-snapshot-local</url>
    </snapshotRepository>
</distributionManagement>
Run Code Online (Sandbox Code Playgroud)

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

你能告诉我我的设置有什么问题吗,我该如何解决这个问题?

gui*_*ido 5

注意:artifactory 6.5.x 中存在一个错误,该错误已在 6.5.2 版中解决,该错误会阻止正确处理过滤后的资源。

${security.getCurrentUsername()}过滤资源的使用,它在 artifactory 中允许将文本文件视为通过 FreeMarker 模板过滤。

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

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