3

我尝试设置部署到本地存储库:

-- 设置.xml --

<server>
  <id>myrepo</id>
  <username>deployer</username>
  <password>123456</password>
</server>

-- pom.xml ---

<repositories>
    <repository>
        <id>myrepo</id>
        <url>http://myserver.com/artifactory/libs-release-local</url>
        <releases>
            <enabled>true</enabled>
            <updatePolicy>always</updatePolicy>
        </releases>
        <snapshots>
            <enabled>false</enabled>
            <updatePolicy>always</updatePolicy>
        </snapshots>
    </repository>
</repositories>

当我执行“mvn deploy”时出现错误:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.4:
deploy (default-deploy) on project xxx: Failed to deploy artifacts: Co
uld not transfer artifact xxx:xxx:war:0.1-20130527.121430-3 from/to myserver.com   
(http://myserver.com:8083/artifactory/libs-snapshot-local): Failed to transfer file: 
http://myserver.com:8083/artifactory/libs-snapshot-local/xxx/0.1-SNAPSHOT
/xxx-0.1-20130527.121430-3.war. Return code is: 401 

神器日志:

2013-05-27 16:14:38,158 [DENIED DEPLOY] libs-snapshot-local:xxx/0.1-SNAPSHOT
/xxx-0.1-20130527.121430-3.pom for anonymous/192.168.6.36.

如果我将服务器/存储库 ID 更改为“myserver.com” - 部署 WORK!但它不适合我,因为在 myserver.com 上使用 svn 插件更改日志不起作用

我尝试将标签“profile”和“mirror”添加到 server.xml 并将“distributionManagement”添加到 pom.xml - 得到相同的错误

服务器/存储库 ID 必须仅命名为我的服务器?

更新1:

我从 pom.xml 中删除标签“存储库”并添加标签“distributionManagment”:

--- pom.xml ---

<distributionManagement>
    <repository>
        <id>myrepo</id>
        <name>myrepo</name>
        <url>http://myserver.com/artifactory/libs-release-local</url>
    </repository>
    <snapshotRepository>
        <id>myrepo</id>
        <name>myrepo</name>
        <url>http://myserver.com/artifactory/libs-snapshots-local</url>
        <uniqueVersion>false</uniqueVersion>
    </snapshotRepository>
</distributionManagement>

(server.xml 没有改变) - 得到同样的错误“部署失败......”

更新2:

尝试...

--- server.xml ---

<profiles>
    <profile>
        <id>artifactory</id>
        <repositories>
            <repository>
                <snapshots>
                    <enabled>false</enabled>
                </snapshots>
                <id>central</id>
                <name>libs-release</name>
                <url>http://myserver.com/artifactory/libs-release-local</url>
            </repository>
            <repository>
                <snapshots />
                <id>snapshots</id>
                <name>libs-snapshot</name>
                <url>http://myserver.com/artifactory/libs-snapshot-local</url>
            </repository>
        </repositories>
    </profile>
</profiles>

<activeProfiles>
    <activeProfile>artifactory</activeProfile>
</activeProfiles>

<server>
    <id>snapshots</id>
    <username>deployer</username>
    <password>123456</password>
</server>
<server>
    <id>central</id>
    <username>deployer</username>
    <password>123456</password>
</server>

--- pom.xml ---

<distributionManagement>
    <repository>
        <id>central</id>
        <name>Internal Releases</name>
        <url>http://myserver.com/artifactory/libs-release-local</url>
    </repository>
    <snapshotRepository>
        <id>snapshots</id>
        <name>Internal Snapshots</name>
        <url>http://myserver.com/artifactory/libs-snapshots-local</url>
        <uniqueVersion>false</uniqueVersion>
    </snapshotRepository>
</distributionManagement>

执行'mvn deploy' - 再次错误:(

Failed to deploy artifacts: Could not transfer artifact xxx:xxx:war:0.1-20130528.050526-1 from/to snapshots (http://myserver.com/artifactory/libs-snapshots-local)
4

2 回答 2

2

'repositories' 标签用于解析,而不是用于部署。我推测'distributionManagment'标签下的存储库ID是'myserver.com',这就是它与settings.xml中的服务器声明匹配的原因

于 2013-05-27T13:46:13.987 回答
0

您的 settings.xml 缺少两个 <server> 节点周围的 <servers> </servers> 标记。- https://maven.apache.org/settings.html#Servers

另外,我会避免使用像“快照”和“中心”这样的通用 ID。如果他们在那里是为了 SO 的目的,这是可以理解的。

这个问题的最后一次更新没有包含具体的错误代码,但在原始错误中它是 401(未经授权),这让我相信由于无效的 settings.xml,它无法找到您的服务器身份验证信息

于 2022-02-08T22:01:33.407 回答