如何在nexus私服添加第三方仓库

2018-02-06  本文已影响689人  大浪滔滔

举例,我们要在maven工程中引入以下组件:

<dependency>
      <groupId>org.hyperic</groupId>
      <artifactId>sigar</artifactId>
      <version>1.6.4</version>
</dependency>

在默认中央仓库http://search.maven.org中没有找到这个组件。接下来,该怎么办呢?

1、搜索第三方jar所在的仓库

浏览器打开http://mvnrepository.com,找到相应的组件。

006tNc79gy1fo6u5a1s36j31kw0zbqe8.jpg

注意,下面红框是该组件所在的第三方仓库:http://repo.typesafe.com/typesafe/maven-releases/

2、在私服中加入该仓库

打开sonata nexus私服,增加一个proxy:


006tNc79gy1fo6uimc247j316e10wajv.jpg

地址为上面的仓库地址,其他为默认值即可。

3、将该仓库加入public group

006tNc79gy1fo6upgr55ej312m10w7dh.jpg

这个public group对应我们在maven的setting.xml中的私有仓库地址:

<mirror>
    <id>nexus</id>
    <mirrorOf>*</mirrorOf>
    <url>http://IP:PORT/nexus/content/groups/public</url>
</mirror>

MAVEN仓库资源搜索的几个网站

http://mvnrepository.com/
http://search.maven.org
https://repository.sonatype.org/index.html

上一篇 下一篇

猜你喜欢

热点阅读