1.Nexus安装与配置

1.Nexus下载
下载地址:http://www.sonatype.org/nexus/go/
下载后的文件:nexus-2.11.4-01-bundle.zip
安装:直接解压到某个目录即可
解压后,会有两个目录:
nexus-2.11.4-01  
sonatype-work :私服的默认仓库
1.1 将bin目录添加到环境变量中
D:\JavaDev\nexus-2.11.4\nexus-2.11.4-01\bin
1.2 配置java文件的路径
打开D:\JavaDev\nexus-2.11.4\nexus-2.11.4-01\bin\jsw\conf\wrapper.conf文件
修改wrapper.java.command=java为你的java.exe文件的路径
例如:
wrapper.java.command=D:\Program Files\Java\jdk1.7.0_07\bin\java
1.3 启动nexus
先安装:nexus install
然后启动:nexus start
C:\Users\Administrator>**nexus install**
wrapper  | nexus installed.
C:\Users\Administrator>**nexus start**
wrapper  | Starting the nexus service...
wrapper  | Waiting to start...
wrapper  | nexus started.
C:\Users\Administrator>
1.4 登陆nexus
地址:http://localhost:8081/nexus
默认用户名密码 admin/admin123

2.Nexus Repositories 介绍
2.1 Repositories介绍
在Nexus的Repositories中,主要有两种类型的工厂hosted和proxy
hosted本地工厂:只是面向内部服务的,面向局域网
3rd party :存放Maven中央仓库中没有的第三方jar包
Releases  :存放Maven中提交的Releases项目
Snapshots :存放Maven中提交的Snaphots项目
proxy代理工厂:
Central:存放从Maven中央工厂中下载下来的jar包
例如:Central中需要配置Maven中央工厂的地址
Apache Snapshots:存放专门从Apache下载的Snapshots的jar包
Codehaus Snapshots:存放专门从Codehaus下载的Snapshots的jar包
2.2 Maven中配置Nexus Repositories
配置Maven不从Maven自身的中央工厂找jar包,而是从这个Nexus私服工厂中找jar包
临时配置(用户配置):表示只针对当前项目的配置方式,只要当前项目找jar包的时候是来Nexus中找,但是如果再有一个新项目。就还是从Maven中来下载jar包了
打开pom.xml添加配置

1
2
3
4
5
6
7
< repositories >
      < repository >
          < id >nexus id >
          < name >Nexus Repository name >
          < url >http://localhost:8081/nexus/content/groups/public/ url >
      repository >
repositories >

其中url的值,就是Public repositories的URL值


全局配置:这样配置表示不管哪个项目,只要局域网内使用Maven下载jar包,都会来Nexus的私服工厂中来下载。
通过修改Maven的setting.xml的全局配置文件
增加一个或者多个profile配置

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
< profiles >
     < profile >
         < id >nexusProfile id >
         < repositories >
           < repository >
             < id >nexus id >
             < name >Nexus Repository name >
             < url >http://localhost:8081/nexus/content/groups/public/ url >
            
             < releases >< enabled >true enabled > releases >
            
             < snapshots >< enabled >true enabled > snapshots >
           repository >
         repositories >
       profile >
profiles >
< activeProfiles >
    
     < activeProfile >nexusProfile activeProfile >
activeProfiles >

2.3 配置Nexus的镜像
配置Nexus的镜像的目的是:有时候我们每个开发人员需要在我们的私服中找jar包,但是如果私服中也没有的话,就会去Maven的中央工厂中找。可能会有这样的需求,就是你们开发人员不允许直接去中央工厂找jar包,你们所需要的jar包都来我们内部的私服来找。如果私服里也找不到,那就是找不到了【通知项目经理需要\*\*.jar包】
同样是在Maven的全局配置文件settings.xml中配置

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
< mirrors >
< mirror >
   < id >nexusMirror id >
  
   
  
   < mirrorOf >* mirrorOf >
   < name >Human Readable Name for this Mirror. name >
   < url >http://localhost:8081/nexus/content/groups/public/ url >
mirror >
mirrors >

当然,如果这里定义mirror,那上面定义的激活profile的定义就没什么意义了,可以直接注释掉

1
2
3
4
< activeProfiles >
    
    
activeProfiles >

 

1.Nexus安装与配置

2.Nexus更新索引

3.发布Maven项目到nexus中

4.按项目类型分配不同的nexus工厂来发布不同的项目

转载于:https://www.cnblogs.com/meet/p/5060864.html

你可能感兴趣的:(1.Nexus安装与配置)