2013-08-16 22 views
2

我用我自己的安装在我的本地机器上的Nexus Web应用程序库的版本。我曾经的Nexus配置了只有一个仓库,一个在那里我存储我的快照:当地的Nexus仓库像个代理对于一些Maven构件

http://localhost:8081/nexus/content/repositories/MySnapshots/ 

需要注意的是Nexus的安装后,我删除了所有默认库和补充只是我自己。 (也许这是一个坏主意?)

当我做一个干净的MVN安装我注意到,一些第三方的文物都是直接从远程仓库下载。例如,这里是从构建输出线之一:

Downloading: http://repo.maven.apache.org/maven2/com/sun/org/apache/xml/internal/resolver/... 

奇怪的是,我看到其他的文物正在经历我的地方联结到最终得到的神器:

Downloading: http://localhost:8081/nexus/content/repositories/MySnapshots/org/apache/maven/wagon/wagon-provider-api... 

请注意下载URL的第一部分是怎么我的本地库,但一切后MySnapshots是从apache.org。

这几乎就像我的Nexus存储库的行为像maven.apache.org代理一些神器下载,但对于其他人,它直接到源。

谁能告诉我为什么发生这种情况?

如果我所有的构建都是成功的,那么我不会被这么多困扰,但有时候,当我编译大型项目时,由于无法找到构件而导致构建失败。

例如,当我尝试建立另一个项目依赖于Eclipse JDT的东西,我得到以下错误:

Downloading: http://localhost:8081/nexus/content/repositories/MySnapshots/eclipse/jdt/core/eclipse.jdt.core 
Could not find artifact eclipse.jdt.core:eclipse.jdt.core 

我不知道这意味着我的Nexus不正常,或配置有真的不是神器eclipse.jdt.com。如果下载没有通过我本地的Nexus存储库,我会调查pom/settings.xml文件。相反,这使我怀疑是否由于我的Nexus配置。

如果你想看到我对Maven的settings.xml和我建立了我的项目POM文件,当我看到这一点,你可以在这里查看它们:

的settings.xml:http://pastebin.com/NvLr5bEA

POM .XML:http://pastebin.com/PJ0P3RaK

+0

这里的大型项目是什么意思? – saurav

+0

我正在尝试自己编译jaxb2插件。 :P该项目有15个maven模块。 –

+0

你能在这里提供完整的日志,同时建立你的模块? 不建议使用外部链接。 – saurav

回答

0

我不认为它是一个代理发行,高达我对当它从Maven的中央回购下载第一种情况的了解,有可能是相同的神器是不是在您的Nexus仓库中,这是为什么要去Maven Central Repo。

在它在你的关系可用,因此反应器并没有试图从Maven的中央回购下载它的第二种情况。

+0

好的想法,但问题是......如果在第二种情况下,它在我的Nexus中可用,它是如何到达的?我从最初的Nexus安装中删除了所有的存储库,然后只添加了我自己的。通过它的? –

2

如果你喜欢使用本地关系作为代理像往常一样比你要配置的设置。xml是这样的:

<mirrors> 
    <mirror> 
     <!--This sends everything else to /public --> 
     <id>nexus</id> 
     <mirrorOf>*</mirrorOf> 
     <url>http://localhost:8081/nexus/content/groups/public</url> 
    </mirror> 
    </mirrors> 
    <profiles> 
    <profile> 
     <id>nexus</id> 
     <!--Enable snapshots for the built in central repo to direct --> 
     <!--all requests to nexus via the mirror --> 
     <repositories> 
     <repository> 
      <id>central</id> 
      <url>http://central</url> 
      <releases><enabled>true</enabled></releases> 
      <snapshots><enabled>true</enabled></snapshots> 
     </repository> 
     </repositories> 
    <pluginRepositories> 
     <pluginRepository> 
      <id>central</id> 
      <url>http://central</url> 
      <releases><enabled>true</enabled></releases> 
      <snapshots><enabled>true</enabled></snapshots> 
     </pluginRepository> 
     </pluginRepositories> 
    </profile> 
    </profiles> 
    <activeProfiles> 
    <!--make the profile active all the time --> 
    <activeProfile>nexus</activeProfile> 
    </activeProfiles> 

棘手的事情是镜像的东西,它将每一个调用重新路由到配置的nexus实例。 你提到的东西像eclipse零件可能会有问题,因为只有少数artifacts可以通过maven central。此外,你应该保留像maven central,release repository和snapshots repository这样的默认值,因为这些是你需要的仓库。