我正在尝试构建包含这两个依赖项的项目:
<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:无法找到工件org.cytoscape:vizmap-api:jar:3.6.0 in nexus(http://our_nexus_server:8081/nexus/content/groups/public/) - &gt; [帮助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/
答案 0 :(得分:1)
为镜像配置添加例外:
<mirrorOf>*,!cytoscape_releases,!cytoscape_snapshots</mirrorOf>
对于这些存储库,它将尝试直接下载它们而不是通过镜像。
但是,干净的解决方案只是将这些存储库作为代理存储库添加到Nexus。否则,每个想要构建项目的人都必须调整他的本地镜像配置。
答案 1 :(得分:1)
如前所述,您只需将多个存储库添加到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>
它将遍历存储库以解决依赖关系。
doc是here
如果托管存储库的服务器需要凭据,请参阅here