简体   繁体   English

Maven存储库代理混乱

[英]maven repository proxy confusion

I am using maven 3.0 ( with nexus setup ) for building my projects and am getting build failures : 我正在使用maven 3.0(带有nexus设置)来构建我的项目,并且遇到构建失败:

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)

My basic confusion is : When maven sees a dependency in the pom.xml , how does it go about looking for artifacts in remote repositories ? 我的基本困惑是: 当maven在pom.xml中看到依赖项时,如何在远程存储库中寻找工件

My current understanding is : 我目前的理解是:

  1. It will first look in the local repo ( .m2/repository ). 首先,它将查找本地存储库(.m2 / repository)。

  2. If it does not find there , then it will try to search the repository specified in settings.xml under repository tag. 如果在那里找到,则它将尝试在存储库标记下搜索settings.xml中指定的存储库 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 ? 下面我提到5个存储库:maven是一个一个地搜索所有这些,还是仅第一个搜索?

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

My last confusion is about proxies section in the settings.xml. 我的最后一个困惑是关于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>

I can tell you we use a local Nexus and have all our users have the following in their settings.xml: 我可以告诉您,我们使用本地Nexus,并且所有用户的settings.xml中都包含以下内容:

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

This causes any call by maven to go to Nexus to get a dependency. 这会导致maven进行的任何调用都转到Nexus以获得依赖关系。 You are right about maven first looking in local .m2. 您首先在本地.m2中查找maven是正确的。

Nexus proxies many repositories and has a union of them all (for the maven processes calling it). Nexus代理许多存储库,并拥有所有存储库的并集(适用于Maven流程调用它)。 This means that a developer's local maven knows only of a single repository: Nexus. 这意味着开发人员的本地专家仅了解一个存储库:Nexus。 Nexus will serve all the needed dependencies id they are in one of its proxied/hosted repositories. Nexus将在其代理/托管存储库之一中提供所有必需的依赖项ID。

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

I hope this gives you some information to get started. 我希望这能给您一些入门的信息。

I strongly urge you to look into Nexus/Maven related configurations at: http://www.sonatype.org/ 我强烈建议您通过以下网址查看与Nexus / Maven有关的配置: http//www.sonatype.org/

The correct setup for using Maven with Nexus is documented in the book Repository Management with Nexus. 《使用Nexus进行存储库管理》一书中介绍了将Maven与Nexus结合使用的正确设置。 The sample settings.xml is here . 示例settings.xml在这里 Read the description and note that you need to add the overrides for the central repository to enable snapshots. 阅读说明,并注意您需要为中央存储库添加替代以启用快照。

Once you have done that you do NOT configured a proxy in your settings.xml since it will be available in your local network without a proxy (typically). 一旦完成,就不要在settings.xml中配置代理,因为它在本地网络中无需代理即可使用(通常)。 Instead you configure the proxy settings in Nexus so that it in turn can get out to the repositories like Central that you are proxying. 相反,您可以在Nexus中配置代理设置,这样它就可以转至您要代理的存储库(如Central)。 The global proxy configuration is documented here and if required you can also configure specifics per proxy repository eg if you need a username/password for a repository you are proxying because it is private.. 此处记录全局代理配置,如果需要,您还可以配置每个代理存储库的详细信息,例如,如果您需要用户名/密码来存储您正在代理的存储库,因为它是私有的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM