You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在Maven settings.xml中正确配置Artifactory密码

Maven Artifactory settings.xml 密码配置问题

我有一个可本地执行mvn clean install并正常构建的Maven项目,现已搭建JFrog Artifactory服务器用于管理项目制品,但不清楚如何在settings.xml的<server>块中正确设置密码。

我在Artifactory中创建了Maven仓库,选择libs-release-local仓库的“set me up”选项自动生成了如下settings.xml文件(已复制到~/.m2/settings.xml):

<?xml version="1.0" encoding="UTF-8"?>
<settings xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.2.0 http://maven.apache.org/xsd/settings-1.2.0.xsd" xmlns="http://maven.apache.org/SETTINGS/1.2.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <servers>
    <server>
      <username>${security.getCurrentUsername()}</username>
      <password>${security.getEscapedEncryptedPassword()!"*** Insert encrypted password here ***"}</password>
      <id>central</id>
    </server>
    <server>
      <username>${security.getCurrentUsername()}</username>
      <password>${security.getEscapedEncryptedPassword()!"*** Insert encrypted password here ***"}</password>
      <id>snapshots</id>
    </server>
  </servers>
  <mirrors>
    <mirror>
      <mirrorOf>*</mirrorOf>
      <name>libs-snapshot</name>
      <url>http://ec2-3-92-61-201.compute-1.amazonaws.com:8081/artifactory/libs-snapshot</url>
      <id>libs-snapshot</id>
    </mirror>
  </mirrors>
  <profiles>
    <profile>
      <repositories>
        <repository>
          <snapshots>
            <enabled>false</enabled>
          </snapshots>
          <id>central</id>
          <name>libs-release</name>
          <url>http://ec2-3-92-61-201.compute-1.amazonaws.com:8081/artifactory/libs-release</url>
        </repository>
        <repository>
          <snapshots />
          <id>snapshots</id>
          <name>libs-snapshot</name>
          <url>http://ec2-3-92-61-201.compute-1.amazonaws.com:8081/artifactory/libs-snapshot</url>
        </repository>
      </repositories>
      <pluginRepositories>
        <pluginRepository>
          <snapshots>
            <enabled>false</enabled>
          </snapshots>
          <id>central</id>
          <name>libs-release</name>
          <url>http://ec2-3-92-61-201.compute-1.amazonaws.com:8081/artifactory/libs-release</url>
        </pluginRepository>
        <pluginRepository>
          <snapshots />
          <id>snapshots</id>
          <name>libs-snapshot</name>
          <url>http://ec2-3-92-61-201.compute-1.amazonaws.com:8081/artifactory/libs-snapshot</url>
        </pluginRepository>
      </pluginRepositories>
      <id>artifactory</id>
    </profile>
  </profiles>
  <activeProfiles>
    <activeProfile>artifactory</activeProfile>
  </activeProfiles>
</settings>

生成该文件时,Artifactory UI还自动生成了一个认证令牌,但未说明用途,我不确定是否应将其作为密码使用。此外,自动生成的settings.xml中密码字段提示需使用base64编码的明文密码,但我不清楚正确的编码流程。

我尝试将<username>设为明文用户名,<password>设为明文密码,返回401错误;将明文密码base64编码后设置为密码,仍出现相同错误:

[INFO] Artifact org.springframework.boot:spring-boot-starter-parent:pom:2.5.1 is present in the local repository, but cached from a remote repository ID that is unavailable in current build context, verifying that is downloadable from [libs-snapshot (http://ec2-3-92-61-201.compute-1.amazonaws.com:8081/artifactory/libs-snapshot, default, releases+snapshots)]
Downloading from libs-snapshot: http://ec2-3-92-61-201.compute-1.amazonaws.com:8081/artifactory/libs-snapshot/org/springframework/boot/spring-boot-starter-parent/2.5.1/spring-boot-starter-parent-2.5.1.pom
[ERROR] [ERROR] Some problems were encountered while processing the POMs:
[WARNING] 'dependencies.dependency.version' for org.springframework.boot:spring-boot-starter-web:jar is either LATEST or RELEASE (both of them are being deprecated) @ line 35, column 22
[FATAL] Non-resolvable parent POM for com.vismark:MicroServiceOne:0.0.1-SNAPSHOT: The following artifacts could not be resolved: org.springframework.boot:spring-boot-starter-parent:pom:2.5.1 (present, but unavailable): Could not transfer artifact org.springframework.boot:spring-boot-starter-parent:pom:2.5.1 from/to libs-snapshot (http://ec2-3-92-61-201.compute-1.amazonaws.com:8081/artifactory/libs-snapshot): status code: 401, reason phrase:  (401) and 'parent.relativePath' points at wrong local POM @ line 6, column 10
 @
[ERROR] The build could not read 1 project -> [Help 1]
[ERROR]
[ERROR]   The project com.vismark:MicroServiceOne:0.0.1-SNAPSHOT (/Users/mc98763/Documents/GitHub/Personal/MicroServiceOne/pom.xml) has 1 error
[ERROR]     Non-resolvable parent POM for com.vismark:MicroServiceOne:0.0.1-SNAPSHOT: The following artifacts could not be resolved: org.springframework.boot:spring-boot-starter-parent:pom:2.5.1 (present, but unavailable): Could not transfer artifact org.springframework.boot:spring-boot-starter-parent:pom:2.5.1 from/to libs-snapshot (http://ec2-3-92-61-201.compute-1.amazonaws.com:8081/artifactory/libs-snapshot): status code: 401, reason phrase:  (401) and 'parent.relativePath' points at wrong local POM @ line 6, column 10 -> [Help 2]
[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/ProjectBuildingException
[ERROR] [Help 2] http://cwiki.apache.org/confluence/display/MAVEN/UnresolvableModelException

我还在pom.xml中添加了如下<distributionManagement>块:

<distributionManagement>
        <repository>
            <id>central</id>
            <name>5fb7025f605d-releases</name>
            <url>http://ec2-3-92-61-201.compute-1.amazonaws.com:8081/artifactory/libs-release</url>
        </repository>
    </distributionManagement>

请问在settings.xml文件中正确设置密码的方法是什么?

内容的提问来源于stack exchange,提问作者Vismark Juarez

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.07 16:05:54