Maven的。存储库认证 [英] Maven. Repository authentication

查看:167
本文介绍了Maven的。存储库认证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试安装部署到本地存储库:

I tried setup deploy to local repository:

- settings.xml -

-- settings.xml --

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

- pom.xml ---

-- 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我有错误:

when I execute "mvn deploy" I got error:

[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插件更改日志

If I change server/repository id to "myserver.com" - deploy WORK! But it does not suit me because that did not work plugin changelog with svn at myserver.com

我尝试添加标签配置文件和镜像到server.xml和distributionManagement到pom.xml - 获得相同的错误

I tried to add tags "profile" and "mirror" to server.xml and "distributionManagement" to pom.xml - getting the same error

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

server/repository id must be named ONLY as my server?

UPDATE1:

我从pom.xml中删除标签'repositoryories',并添加了标签'distributionManagment':

I remove tag 'repositories' from pom.xml and added tag 'distributionManagment':

--- pom.xml ---

--- 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没有更改) - 获得相同的错误无法部署...

(server.xml has not changed) - getting the same error "Failed to deploy..."

更新2:

尝试...

--- server.xml ---

--- 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 ---

--- 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' - 再次错误:(

execute 'mvn deploy' - again error :(

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)


推荐答案

使用'repositoryories'为了解决而不是部署,我推测在distributionManagment标签下的存储库的id是'myserver.com',这就是为什么它与settings.xml中的服务器声明相匹配

The 'repositories' tag is used for resolution, not for deployment. I'd speculate that the id of the repository under 'distributionManagment' tag is 'myserver.com', that's why it matches the server declaration in settings.xml

这篇关于Maven的。存储库认证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆