Maven存储库代理混乱 [英] maven repository proxy confusion

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

问题描述

我正在使用maven 3.0(带有nexus设置)来构建我的项目,并且遇到构建失败:

I am using maven 3.0 ( with nexus setup ) for building my projects and am getting build failures :

Caused by: org.sonatype.aether.transfer.ArtifactNotFoundException: Could not find artifact directory:apacheds-core:jar:${apacheds_version} in central (http://localhost:8081/nexus/content/repositories/central)
at org.sonatype.aether.connector.wagon.WagonRepositoryConnector$4.wrap(WagonRepositoryConnector.java:945)
at org.sonatype.aether.connector.wagon.WagonRepositoryConnector$4.wrap(WagonRepositoryConnector.java:940)

我的基本困惑是:当maven在pom.xml中看到依赖项时,如何在远程存储库中寻找工件?

我目前的理解是:

  1. 它将首先在本地存储库(.m2/repository)中查找.

  1. It will first look in the local repo ( .m2/repository ).

如果没有找到 ,则它将尝试在 repository 标记下搜索settings.xml中指定的存储库. 问题:它是否尝试了所有提到的存储库. 还是仅第一个?下面我提到了5个仓库:maven是一个一个地搜索所有这些,还是只是第一个?

If it does not find there , then it will try to search the repository specified in settings.xml under repository tag. Question : Does it try all the repositories mentioned . or Just the first one ? Below I have mentioned 5 repos : does maven search all these one by one or just the first one ?

<repositories> <repository> <id>central</id> <url>http://localhost:8081/nexus/content/repositories/central</url> </repository> <repository> <id>remote</id> <url>http://localhost:8081/nexus/content/repositories/remote-proxy-nexus-central</url> </repository> <repository> <id>thirdParty</id> <url>http://localhost:8081/nexus/content/repositories/thirdparty</url> </repository> <repository> <id>codehaus</id> <url>http://localhost:8081/nexus/content/repositories/codehaus-snapshots</url> </repository> <repository> <id>public</id> <url>http://localhost:8081/nexus/content/groups/public</url> </repository> </repositories>

<repositories> <repository> <id>central</id> <url>http://localhost:8081/nexus/content/repositories/central</url> </repository> <repository> <id>remote</id> <url>http://localhost:8081/nexus/content/repositories/remote-proxy-nexus-central</url> </repository> <repository> <id>thirdParty</id> <url>http://localhost:8081/nexus/content/repositories/thirdparty</url> </repository> <repository> <id>codehaus</id> <url>http://localhost:8081/nexus/content/repositories/codehaus-snapshots</url> </repository> <repository> <id>public</id> <url>http://localhost:8081/nexus/content/groups/public</url> </repository> </repositories>

我最后的困惑是关于settings.xml中的代理部分.这些位置是什么:

My last confusion is about proxies section in the settings.xml. What are these locations :

 <proxy>
  <id>remote-proxy-nexus-central</id>
  <active>true</active>
  <protocol>http</protocol>
  <host>repo1.maven.org/maven2</host>
  <port>8080</port>

</proxy>

推荐答案

我可以告诉您我们使用的是本地Nexus,并且所有用户的settings.xml中都包含以下内容:

I can tell you we use a local Nexus and have all our users have the following in their settings.xml:

<mirror>
    <id>our-mirror</id>
    <name>Org Public Mirror</name>
    <url>http://host/nexus/content/groups/public</url>
    <mirrorOf>*</mirrorOf>
</mirror>

这将导致maven进行的任何呼叫都转到Nexus以获取依赖关系.您首先在本地.m2中查找maven是正确的.

This causes any call by maven to go to Nexus to get a dependency. You are right about maven first looking in local .m2.

Nexus代理许多存储库,并具有所有存储库的并集(适用于Maven进程调用它). 这意味着开发人员的本地专家仅知道一个存储库:Nexus. Nexus将在其代理/托管存储库之一中提供所有必需的依赖项ID.

Nexus proxies many repositories and has a union of them all (for the maven processes calling it). This means that a developer's local maven knows only of a single repository: Nexus. Nexus will serve all the needed dependencies id they are in one of its proxied/hosted repositories.

对于代理服务器,我们有一个组织代理服务器,但是Nexus在组织中(它已将代理服务器配置为允许访问外部世界),因此maven不需要此特定配置.

As for Proxy, we have an organization proxy, but the Nexus is in the org (it has the proxy configured to allow access to the outer world), so maven does not need this specific configuration.

我希望这会为您提供一些入门的信息.

I hope this gives you some information to get started.

我强烈建议您通过以下网址查看与Nexus/Maven相关的配置: http://www.sonatype.org/

I strongly urge you to look into Nexus/Maven related configurations at: http://www.sonatype.org/

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

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