【Maven】Nexus(Maven仓库私服)下载与安装

Nexus介绍

  Nexus 是Maven仓库管理器,如果你使用Maven,你可以从Maven中央仓库 下载所需要的构件(artifact),但这通常不是一个好的做法,你应该在本地架设一个Maven仓库服务器,在代理远程仓库的同时维护本地仓库,以节省带宽和时间,Nexus就可以满足这样的需要。此外,他还提供了强大的仓库管理功能,构件搜索功能,它基于REST,友好的UI是一个extjs的REST客户端,它占用较少的内存,基于简单文件系统而非数据库。这些优点使其日趋成为最流行的Maven仓库管理器。

Nexus下载

    NEXUS OSS [OSS = Open Source Software,开源软件——免费]

    NEXUS PROFESSIONAL -FREE TRIAL [专业版本——收费]。

    

      

Nexus安装

  •  安装环境:操作系统:Linxu(CentOS)
  •    将压缩包解压到/usr目录下,nexus里面有2个文件夹,第一个文件夹是核心文件,第二个文件夹用来存储下载下来的jar:

    

    

  •  修改端口,进入nexus/nexubs-2.13.0-01/conf目录下,编辑nexus.properties文件,命令:vim nexus.properties

    

    

  •  启动nexus,进入nexus/nexubs-2.13.0-01/bin目录,

    

    • 运行命令:./nexus     //可以查看有那些运行命令

    

    • 运行命令:./nexus start      //启动nexus

    

    注意:可能会报错,报上面错误时:需要修改运行的用户,修改运行文件 nexus,命令:vim nexus,将RUN_AS_USER修改为root;

    

    

    保存之后,再次启动nexus,运行命令:./nexus start 

    

  •  查看nexus 控制台,命令:./nexus console

    

  •  在浏览器进行访问。地址:http://ip:端口/nexus

    

  •  在网页上的右上角进行登录,默认用户名:admin,密码:admin123

    

    

 



3. 进入Nexus管理页面

http://localhost:8081/nexus/index.html

默认密码 admin admin123

 

点击Repositories ,可以看到仓库列表,包括下面几种:

Public Repositories    仓库组 
3rd part                     三方库,可以上传jar包到这个仓库
Central                      maven中心仓库
Releases                  自己项目中发布的构建 
Snapshots                 trunk 下开发一个项目

 

这里需要注意把Central 仓库的自动更新设置为True:


更新之后能看到Index:


 

4. 在settings.xml中使用本地仓库:

~/.m2 下新建settings.xml :

复制代码
<profile>  
          <id>dev</id>  
          <repositories>  
          <repository>  
            <id>nexus</id>                                    
                 <url>http://127.0.0.1:8081/nexus/content/groups/public/</url>                        
            <releases>  
                <enabled>true</enabled>  
                </releases>  
            <snapshots>  
             <enabled>true</enabled>  
            </snapshots>  
             </repository>  
          </repositories>  
          
         <pluginRepositories>  
  
                <pluginRepository>  
  
                    <id>nexus</id>  
  
                    <url>http://127.0.0.1:8081/nexus/content/groups/public</url>  
  
                    <releases>  
  
                        <enabled>true</enabled>  
  
                    </releases>  
  
                    <snapshots>  
  
                        <enabled>true</enabled>  
  
                    </snapshots>  
  
                </pluginRepository>  
  
            </pluginRepositories>  
  
        </profile>  
  </profiles>

   <activeProfiles>  
        <activeProfile>dev</activeProfile>  
   </activeProfiles> 
复制代码

 方式二

复制代码
<profile>
      <id>dev</id>
      <activation>
        <jdk>1.7</jdk>
      </activation>
      <repositories>
        <repository>
          <id>devRepos</id>
          <name>dev Repository</name>
          <url>http://127.0.0.1:8081/nexus/content/repositories/devRepos/</url>
          <layout>default</layout>
        </repository>
      </repositories>
</profile>
复制代码

 

现在可以通过maven实验一下:

mvn archetype:create  -DgroupId=com.yourcompany -DartifactId=myproject  -DarchetypeArtifactId=maven-archetype-webapp

 

lvkun@lvkun-duitang:~/workspace$ mvn archetype:create  -DgroupId=com.yourcompany -DartifactId=myproject  -DarchetypeArtifactId=maven-archetype-webapp 
[INFO] Scanning for projects...
Downloading: http://127.0.0.1:8081/nexus/content/groups/public/org/apache/maven/plugins/maven-clean-plugin/2.4.1/maven-clean-plugin-2.4.1.pom
Downloaded: http://127.0.0.1:8081/nexus/content/groups/public/org/apache/maven/plugins/maven-clean-plugin/2.4.1/maven-clean-plugin-2.4.1.pom (5 KB at 27.2 KB/sec)
Downloading: http://127.0.0.1:8081/nexus/content/groups/public/org/apache/maven/plugins/maven-plugins/18/maven-plugins-18.pom
Downloaded: http://127.0.0.1:8081/nexus/content/groups/public/org/apache/maven/plugins/maven-plugins/18/maven-plugins-18.pom (13 KB at 409.6 KB/sec)
Downloading: http://127.0.0.1:8081/nexus/content/groups/public/org/apache/maven/maven-parent/16/maven-parent-16.pom
Downloaded: http://127.0.0.1:8081/nexus/content/groups/public/org/apache/maven/maven-parent/16/maven-parent-16.pom (23 KB at 463.8 KB/sec)
Downloading: http://127.0.0.1:8081/nexus/content/groups/public/org/apache/apache/7/apache-7.pom
Downloaded: http://127.0.0.1:8081/nexus/content/groups/public/org/apache/apache/7/apache-7.pom (15 KB at 563.7 KB/sec)
Downloading: http://127.0.0.1:8081/nexus/content/groups/public/org/apache/maven/plugins/maven-clean-plugin/2.4.1/maven-clean-plugin-2.4.1.jar
Downloaded: http://127.0.0.1:8081/nexus/content/groups/public/org/apache/maven/plugins/maven-clean-plugin/2.4.1/maven-clean-plugin-2.4.1.jar (23 KB at 459.9 KB/sec)



http://blog.csdn.net/shenshen123jun/article/details/9084293#

 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值