【问题标题】:How to force maven to get dependencies from another nexus repositorie如何强制 maven 从另一个 nexus 存储库获取依赖项
【发布时间】:2018-07-22 19:08:00
【问题描述】:

我正在尝试构建包含这两个依赖项的项目:

 <dependency>
            <groupId>org.cytoscape</groupId>
            <artifactId>vizmap-api</artifactId>
            <version>3.6.0</version>
        </dependency>
        <dependency>
            <groupId>org.cytoscape</groupId>
            <artifactId>viewmodel-api</artifactId>
            <version>3.6.0</version>
        </dependency>

我还在我的 POM 中包含了这个存储库标签:

 <repositories>
    <repository>
        <id>cytoscape_snapshots</id>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
        <releases>
            <enabled>false</enabled>
        </releases>
        <name>Cytoscape Snapshots</name>
        <url>http://code.cytoscape.org/nexus/content/repositories/snapshots/</url>
    </repository>
    <repository>
        <id>cytoscape_releases</id>
        <snapshots>
            <enabled>false</enabled>
        </snapshots>
        <releases>
            <enabled>true</enabled>
        </releases>
        <name>Cytoscape Releases</name>
        <url>http://code.cytoscape.org/nexus/content/repositories/releases/</url>
    </repository>
</repositories>

然后我在构建过程中遇到了这个错误:

[错误] 无法在项目 CyPlugin 上执行目标:无法解析项目 GraphSYSBIO:CyPlugin:bundle:1.0-SNAPSHOT 的依赖项:无法解析以下工件:org.cytoscape:vizmap-api:jar:3.6。 0, org.cytoscape:viewmodel-api:jar:3.6.0: 在nexus (http://our_nexus_server:8081/nexus/content/groups/public/) 中找不到工件org.cytoscape:vizmap-api:jar:3.6.0 -> [帮助1]

在我的 settings.xml 中,我使用的是代理:

<proxies>
    <!-- proxy | Specification for one proxy, to be used in connecting to the 
        network. | -->
     <proxy>
        <id>optional</id>
        <active>true</active>
        <protocol>http</protocol>
        <username>proxyuser</username>
        <password>proxypass</password>
        <host>ourHost</host>
        <port>8080</port>
        <nonProxyHosts>*localAddress</nonProxyHosts>
    </proxy>
</proxies>

也使用镜子:

<mirrors>
    <!-- mirror | Specifies a repository mirror site to use instead of a given 
        repository. The repository that | this mirror serves has an ID that matches 
        the mirrorOf element of this mirror. IDs are used | for inheritance and direct 
        lookup purposes, and must be unique across the set of mirrors. | -->
    <mirror>
          <id>nexus</id>
          <mirrorOf>*</mirrorOf>
          <name>Our Local Nexus Repo</name>
                  <url>our_nexus:8081/nexus/content/groups/public/</url>   
</mirror>
</mirrors>

我的问题是:如何告诉 maven 在 cytoscape.org/nexus/ nexus 中而不是在我们的 nexus 服务器上查找这两个依赖项。

镜像可以解决这个问题吗?

cytoscape.org/nexus/ 的链接是: http://code.cytoscape.org/nexus/content/repositories/releases/org/cytoscape/vizmap-api/3.6.0/

【问题讨论】:

  • 您好,您找到解决此问题的方法了吗?

标签: maven repository nexus maven-mirroring


【解决方案1】:

为您的镜像配置添加一个例外:

<mirrorOf>*,!cytoscape_releases,!cytoscape_snapshots</mirrorOf>

对于那些存储库,它将尝试直接下载它们而不是通过镜像。

但是,干净的解决方案是将这些存储库作为代理存储库添加到您的 Nexus。否则,每个想要构建您的项目的人都必须调整他的本地镜像配置。

【讨论】:

  • 你好,谢谢你的回复。我已经尝试过,以及 Essex Boy 解决方案提议,但我拒绝访问:code.cytoscape.org/nexus/content/repositories/releases/org/…,ReasonPhrase:Forbidden。 -> [Help 1] [ERROR] / 我不确定如何将这 2 个存储库添加为代理存储库。文档中是否有任何示例
  • ?从消息中可以看出,某些东西正在阻止访问。您是否在公司防火墙后面
【解决方案2】:

如前所述,您可以简单地将多个存储库添加到您的 settings.xml

 <repositories>
   <repository>
     <id>my-repo2</id>
     <name>your custom repo</name>
     <url>http://jarsm2.dyndns.dk</url>
   </repository>
   <repository>
     <id>my-repo3</id>
     <name>your custom repo</name>
     <url>http://jarsm3.dyndns.dk</url>
   </repository>
 </repositories>

它将通过存储库来解决依赖关系。

文档是here

如果托管存储库的服务器需要凭据,请参阅here

【讨论】:

  • 嘿,埃塞克斯男孩,感谢您的回复。我遇到了和以前一样的错误,但是当我按照 dunni 的建议添加“*,!cytoscape_releases,!cytoscape_snapshots”时,我得到了拒绝访问。不知道下一步该做什么
  • 我已经有一个服务器标签但没有 ssh 部分...仍然没有运气
猜你喜欢
  • 2011-03-26
  • 2017-01-23
  • 2023-03-30
  • 2013-06-05
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-06-05
  • 1970-01-01
相关资源
最近更新 更多