Nexus3.6安装、setting配置和jar包deploy

Nexus 是Maven仓库管理器,如果你使用Maven,你可以从Maven中央仓库 下载所需要的构件(artifact),但这通常不是一个好的做法,在本地架设一个Maven仓库服务器,在代理远程仓库的同时维护本地仓库,以节省带宽和时间,Nexus就可以满足这样的需要。

此外,他还提供了强大的仓库管理功能,构件搜索功能,它基于REST,友好的UI是一个extjs的REST客户端,它占用较少的内存,基于简单文件系统而非数据库。

还有,搭建团队Nexus (私服),方便于我们自定义的jar和war存档管理,可以避免了团队使用的工具包不一致的问题。

1.下载

http://www.sonatype.com/download-oss-sonatype

2.安装/卸载(install\uninstall)【本文以Windows环境为例】

cmd进入到解压目录:E:\nexus3.6\nexus-3.6.1-02-win64\nexus-3.6.1-02\bin

  1. E:\nexus3.6\nexus-3.6.1-02-win64\nexus-3.6.1-02\bin>nexus.exe /install
  2. Installed service 'nexus'.

 

3.启动服务

cmd窗口:输入services.msc 找到nexus服务,点击启动

4.访问端口配置

  1. 进入E:\nexus3.6\nexus-3.6.1-02-win64\nexus-3.6.1-02\etc目录,打开nexus-default.properties文件
  2. ,找到application-port=9090,修改成你自己的端口
## DO NOT EDIT - CUSTOMIZATIONS BELONG IN $data-dir/etc/nexus.properties
##
# Jetty section
application-port=8081
application-host=0.0.0.0
nexus-args=${jetty.etc}/jetty.xml,${jetty.etc}/jetty-http.xml,${jetty.etc}/jetty-requestlog.xml
nexus-context-path=/
# Nexus section
nexus-edition=nexus-pro-edition
nexus-features=\
 nexus-pro-feature

 

5.启动/停止nexus

  1. cmd窗口 -> net start nexus(启动服务)
  2. net stop nexus(停止服务)

6.访问地址

  • http://ip:端口/
  • 默认账号密码:admin/admin123

7.访问地仓库类型

  1. hosted 宿主仓库:主要用于部署无法从公共仓库获取的构件(如 oracle JDBC 驱动)以及自己或第三方的项目构件;
  2. proxy 代理仓库:代理公共的远程仓库;
  3. group 仓库组Nexus 通过仓库组的概念统一管理多个仓库,这样我们在项目中直接请求仓库组即可请求到仓库组管理的多个仓库。

 

 

Nexus3.6安装、setting配置和jar包deploy_第1张图片 访问地仓库类型

8.配置私服(settings.xml



    
    D:\Java\Maven\m2\repository
    
    
    
    
        
            
            nexus
            
            admin
            admin123
        
        
        
            
            newcapec-zhifu-releases
            
            admin
            admin123
        
        
        
            
            newcapec-zhifu-snapshots
            
            admin
            admin123
        
    
    
    
        
            
            nexus
            
            *
            central repository
            
            http://192.168.112.61:8081/repository/maven-public/
        
    
    
    
    
    
    
        
            nexus
            
            
                
                
                    nexus
                    
                    Nexus Release Snapshot Repository
                    
                    http://192.168.112.61:8081/repository/maven-releases/
                
                
                    true
                
                
                    true
                
            
            
            
            
            
                
                    nexus
                    Nexus Release Snapshot Repository
                    http://192.168.112.61:8081/repository/maven-releases/
                    
                        true
                    
                    
                        true
                    
                
            
        
        
        
            jdk18
            
                
                true
                
                1.8
            
            
                1.8
                1.8
                1.8
            
        
    
    
    
        
        nexus
    

9.上传jar包到Nexus

9.1 pom方式:

  1. pom.xml中添加,和dependencies属于同一级别,在project级别下
    
    
     
        newcapec-zhifu-releases
        newcapec-zhifu-releases
        http://192.168.112.61:8081/repository/newcapec-zhifu-releases/
     
     
        newcapec-zhifu-snapshots
        newcapec-zhifu-snapshots
        http://192.168.112.61:8081/repository/newcapec-zhifu-snapshots/
     
    

     

  2. id为要上传的repository的唯一标示,url为要上传的repository的路径
  3. mvn deploy即可
Nexus3.6安装、setting配置和jar包deploy_第2张图片 打包上传进度

 

Nexus3.6安装、setting配置和jar包deploy_第3张图片 上传成功后-私服显示

 

9.2 命令方式:

  1. mvn deploy:deploy-file -DgroupId=xxx.xxx -DartifactId=xxx -Dversion=0.0.2 -Dpackaging=jar 
  2. -Dfile=D:\xxx.jar -Durl=http://xxx.xxx.xxx.xxx:8081/repository/3rdParty/ -DrepositoryId=3rdParty
  1. 其中-DgroupId 为上传的jargroupId
  2. -DartifactId 为上传的jarartifactId
  3. -Dversion 为上传的jar的需要被依赖的时候的版本号
  4. 然后是-Dpackagingjar,-Dfilejar包路径
  5. -Durl 为要上传的路径,可以通过以下方式获取到
  6. -DrepositoryId repository的唯一标示,跟第二步中赋权配置的server相同

9.3 页面上传(Upload):

Nexus3.9版本支持界面上传(Nexus2.x的版本也支持)

 

参考来源:http://blog.csdn.net/iopfan/article/details/71107686

你可能感兴趣的:(Maven)