配置maven内网仓库

下面我们直接进入正题,当我们启动好nexus后。在浏览器地址栏里输入http://host_address:8081/nexus就来到了这样一个仓库管理页面,应该是ExtJs做了,界面很漂亮!

这里写图片描述

1:登录。默认的管理员用户和密码:admin/admin123。

2:登录之后点击左侧的Repositories,在打开的页面中可以看到默认配置了很多的Repository。

这里写图片描述

看完图片,稍微解释一下这些仓库。

首先看到Type这一列,这一列描述了仓库的类型,总共是四个种类。

proxy:顾名思义这个仓库是一个代理仓库,如Central这个代理的就是maven的中央仓库。

local:即本地仓库,这个仓库主要是为了存放第三方的jar(如ojdbc.jar这一类,中央仓库不存在的第三方jar包)和

组内的开发的模块jar包,一般会建2个仓库区分snapshots和release。

virtual:这个是虚拟的一个仓库。你可以把它想象成一个快捷方式,如图的Central M1是为了兼容M1用户,这个仓库链接的地址就是Central。

group:这个姑且叫做聚合仓库吧。他的主要作用是通过对实体仓库(proxy、hosted)进行聚合,对外暴露一个统一的地址。

3:配置聚合仓库。在配置之前先开启maven中央仓库的索引下载。

将download remoting indexs配置为true。

这里写图片描述

右键Central Repository在菜单中点击Repair index。修补索引,nexus会自己下载索引,大概70M的一个文件。

这里写图片描述

配置聚合仓库。

这里写图片描述

OK!到此需要配置的信息就都配置好了。剩下的是修改.m2目录下的settings.xml文件了。

<server>  
    <id>nexus</id>  
    <username>deployment</username>  
    <password>deployment</password>  
</server>

<profiles>
    <profile>
        <id>myProfile</id>
        <repositories>
            <repository>
                <id>myRepository</id>
                <name>Repository for me</name>
                <url>http://192.168.1.172:8081/nexus/content/groups/public</url>
            </repository>
        </repositories>
    </profile>
</profiles>

<activeProfiles>
    <activeProfile>myProfile</activeProfile>
</activeProfiles>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
这里的<server>节点下的用户名和密码可以在nexus的管理台配置。步骤:security——users——右键deployment

——Set Password。 

![这里写图片描述](https://img-blog.csdn.net/20160919144738227)

这样一来所有的配置就结束了。测试一下。
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
mvn compile;

Downloading: http://192.168.1.172:8081/nexus/content/groups/public/com/oracle/ojdbc14/10.2.0.5.0/ojdbc14-10.2.0.5.0.jar
Downloaded: http://192.168.1.172:8081/nexus/content/groups/public/com/oracle/ojdbc14/10.2.0.5.0/ojdbc14-10.2.0.5.0.jar (1533 KB at 7262.5 KB/sec)
  • 1
  • 2
  • 3
  • 4
可以看到是从我们的内网仓库下载的jar包。而且速度很棒,达到了7262.5 KB/sec差不多7m/s。



结尾彩蛋:ojdbc.jar这类第三方jar导入内网仓库的方法。按照箭头方向一步步走,你这么聪明肯定能搞定的啦。
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

这里写图片描述

https://my.oschina.net/u/255289/blog/307447

猜你喜欢

转载自blog.csdn.net/qq_41424661/article/details/79975341