1.nexus 介绍
    是开源的,用该框架架设maven私有服务器
 
2.nexus私服环境搭建
    把nexus.war包放到tomcat的webapps下面
    浏览且登录
    用户名:admin
    密码:admin123
 
3.关于中央仓库注意事项
    地址:目前来说:http:repo1.maven.org/maven2/是正真的maven中央仓库的地址,该地址内置在maven的源码中 其他的都是镜像
    索引:中央仓库带有索引文件以方便用户对其搜索,完整的索引文件大小为60M,索引每周更新一次
    黑名单:如果某个IP地址恶意的下载中央仓库内容,例如全公司100台机器使用一个IP反复下载,这个IP会进入黑名单,因此稍有规模的使用maven时,应该使用Nexus架设私服
 
为什么要使用nexus私服    
1.开发人员过多,是公司IP地址被记录黑名单,无法下载
2.有些项目组没有外网,不能远程访问仓库地址,只能在局域网搭建nexus服务器,开发人员连接这台服务器
 
 
4.nexus仓库 (私有服务器  maven仓库)
    -hosted :宿主仓库,该仓库属于该公司私有的 内部项目的发布仓库
        Hosted代表宿主仓库,用来发布一些第三方不允许的组件,比如oracle驱动、比如商业软件jar包。
        (1)3rd part :第三方依赖的仓库,这个数据通常是由内部人员自行下载之后发布上去
        (2)snapshot:测试版本、镜像版本   发布内部的SNAPSHOT模块的仓库
        (3)release : 发型的版本 内部的模块中release模块的发布仓库
    -proxy:代理仓库   从远程中央仓库中寻找数据的仓库
        Proxy 代表代理远程的仓库,最典型的就是Maven官方中央仓库、JBoss仓库等等。如果构建的Maven项目本地仓库没有依赖包,那么就会去这个代理站点去 下载,那么如果代理站点也没有此依赖包,就回去远程中央仓库下载依赖,这些中央仓库就是proxy。代理站点下载成功后再下载至本机。
    -group: 仓库组    : 虚拟的概念  可以包含其它的仓库  组仓库用来方便我们开发人员进行设置的仓库
 
 

5.下载Maven仓库索引 手动下载

首先将索引下载到本地,下载地址:nexus-maven-repository-index.zip http://download.csdn.net/detail/pk490525/6520295

解压索引压缩包,将里面内容全部拷贝

 

关闭当前Nexus私服,打开Nexus目录%Nexus_Home%\sonatype-work\nexus\indexer\central-ctx,首先删除当前目录里所有内容,然后粘贴所下载的索引,最后启动Nexus私服,索引生效。

6.修改Maven配置文件从Nexus下载构件

1) 如果想对操作系统的所有用户统一配置maven,则只需修改maven\conf\setting.xml 文件就可以了,如果只想对用户单独配置maven,只需将conf\setting.xml文件复制到C:\Documents and Settings\Administrator\.m2文件夹下(我这里假设系统装在c盘,用户为Administrator)。
 
2)  打开setting.xml文件,可以看到如下代码:
  1. <!-- localRepository
  2. | The path to the local repository maven will use to store artifacts.
  3. |
  4. | Default: ~/.m2/repository
  5. <localRepository></localRepository>
  6. -->
表示如果不设置localRepository,maven会默认将本地仓库建到/.m2/repository文件夹下。
设置localRepository如下代码所示:<localRepository>F:\myCenterRepository</localRepository>   
 
7.在POM.xml文件中配置Nexus仓库
在项目的pom文件中添加如下代码:

 <repositories>
<repository>
<id>nexus</id>
<name>my-nexus-repository</name>
<url>http://127.0.0.1:8088/nexus-2.9.0/content/groups/public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>nexus</id>
<name>my-nexus-repository</name>
<url>http://127.0.0.1:8088/nexus-2.9.0/content/groups/public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
 
8.在setting.xml文件中配置Nexus仓库
1)maven提供了profile来配置仓库信息,如下所示:
    <profiles>
<profile>
<id>myprofile</id>
<repositories>
<repository>
<id>central</id>
<url>http://central</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<url>http://central</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
 
2) 激活profile
    <activeProfiles>  
        <activeProfile>myprofile</activeProfile>  
    </activeProfiles>  
 

3)配置镜像

 
    <mirrors>  
        <mirror>     
         <id>nexus</id>      
         <url>http://127.0.0.1:8088/nexus-2.9.0/content/groups/public/</url>     
         <mirrorOf>*</mirrorOf>     
       </mirror>  
     </mirrors>  
 
9 部署构件到Nexus仓库

maven部署

1) 修改pom文件

在pom文件中添加如下配置:

Xml代码  
  1. <distributionManagement>
  2. <repository>
  3. <id>my-nexus-releases</id>
  4. <url>http://127.0.0.1:7788/nexus/content/repositories/releases/</url>
  5. </repository>
  6. <snapshotRepository>
  7. <id>my-nexus-snapshot</id>
  8. <url>http://127.0.0.1:7788/nexus/content/repositories/snapshots/</url>
  9. </snapshotRepository>
  10. </distributionManagement>
 2)在setting.xml文件中添加认证信息:
Xml代码  
<servers>
<server>
<id>my-nexus-releases</id>
<username>admin</username>
<password>admin123</password>
</server>
<server>
<id>my-nexus-snapshot</id>
<username>admin</username>
<password>admin123</password>
</server>
</servers>
 上面的配置中我用的是超级管理员的账户,开发项目中可以改为具有部署构件权限的用户就可以了。

3)执行部署

测试的构件项目信息如下:

Xml代码  
    <groupId>com.ez</groupId>
<artifactId>TestJar</artifactId>
<version>1.0</version>
<packaging>jar</packaging>
<name>TestJar</name>

从上面的信息中可以看出构件为发布版本,所以部署构件的话会自动部署至releases仓库中。

在命令行中执行:mvn clean deploy

如果之前没用执行过该命令,maven会自动到中央仓库中下载部署所需的插件。最后在命令行中看到如下所示就代表构件已经部署成功。

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Nexus私服的搭建的更多相关文章

  1. maven nexus 私服的搭建学习

    之前对maven有过初步的了解与认识,自己也创建过项目使用其来管理,但都是非常粗浅的操作,今天在高人的指点下,也学着在自己的电脑上搭建一个maven私服,虽然技术难度也不高,但为了更深层次的提高,这些 ...

  2. nexus私服linux搭建问题

    一.最近搭建nexus私服,从官网下载下来总是报503服务器无效,很是无奈,最后在网上找到一个可以用的 收藏起来,这里给大家共享一下 下载地址:http://pan.baidu.com/s/1kT3U ...

  3. window下Nexus私服高级搭建

    环境是:nexus-2.1.1.maven-3.0.4.jdk-1.6.0_32 一.用admin用户登陆nexus nexus的下载和安装都很简单 1.下载 http://www.sonatype. ...

  4. nexus私服的搭建和使用

  5. 【转】nexus Maven 环境搭建

    http://www.cnblogs.com/quanyongan/archive/2013/04/24/3037589.html 为什么要搭建nexus私服,原因很简单,有些公司都不提供外网给项目组 ...

  6. Linux_Centos中搭建nexus私服

    1.在Linux下搭建Nexus私服 1).下载并且解压      下载  nexus-2.11.2-03-bundle.zip      unzip nexus-2.11.2-03-bundle.z ...

  7. Window下Nexus私服搭建

    项目组大部分人员不能访问maven的central repository,因此在局域网里找一台有外网权限的机器,搭建nexus私服,然后开发人员连到这台私服上  环境是:nexus-2.1.1.mav ...

  8. Linux 安装配置maven3.0 以及搭建nexus私服

    http://carvin.iteye.com/blog/785365 一.软件准备 1.apache-maven-3.0-bin.tar.gz 下载地址:http://www.apache.org/ ...

  9. 搭建nexus私服(maven)

    这里提供nexus的直接下载页面的链接: https://www.sonatype.com/download-oss-sonatype maven获取依赖jar包是从中央仓库获取,但很莫名的出现jar ...

随机推荐

  1. WINDOWS下配置SVN代码管理

    服务器端使用 visualsvn server,客户端使用tortoiseSvn. 一.服务器端 1.首先,下载visualsvn server,安装到服务器.下载地址: http://www.vis ...

  2. 安卓Recovery模式该怎么用?【转】

    本文转载自:http://android.baike.com/article-109914.html 安卓系统出了名的刷机刷机再刷机,说起刷机就不能不谈Recovery模式,这项刷机过程中最重要的一到 ...

  3. SqlServer 自动备份策略设置

    企业管理器中的Tools,Database Maintenance Planner,可以设置数据库的定期自动备份计划.并通过启动Sql server Agent来自动运行备份计划.具体步骤如下: 1. ...

  4. 批量梯度下降(Batch gradient descent) C++

    At each step the weight vector is moved in the direction of the greatest rate of decrease of the err ...

  5. 第2章 安装Nodejs 2-4 Linux下安装Nodejs

    linux下编译安装Nodejs  GCC和G++分别是GNU的C和C++编译器.它们在执行编译工作的时候把源代码通过预处理转化成汇编语言生成.i后缀的文件,再由汇编变成目标机器代码,最后连接目标代码 ...

  6. PCB 工程系统 模拟windows域帐号登入

    一.需求描述: 对于PCB制造企业来说,基本都采用建立共享目享+域名管控权限,好像别的大多数行业都是这样的吧.呵呵 在实际应用中,经常会有这样的问题,自己登入的帐号没有共享目录的权限,但又想通过程序实 ...

  7. vmware 14黑屏处理办法

    从12升级到了14,但是发现所有的虚拟机都不能用了,黑屏.挂起的时候反而会显示界面,但是继续运行就是黑屏. 记录下解决办法. 修复LSP 以管理员身份运行CMD命令: netsh winsock re ...

  8. B - Double Cola

    Problem description Sheldon, Leonard, Penny, Rajesh and Howard are in the queue for a "Double C ...

  9. Oracle数据库基础知识总结(一)

    数据库名.实例名.数据库域名.全局数据库名.服务名,这是几个令很多初学者容易混淆的概念.相信很多初学者都与我一样被标题上这些个概念搞得一头雾水. 我们现在就来把它们弄个明白. 一.数据库名 什么是数据 ...

  10. (转)基于Metronic的Bootstrap开发框架经验总结(7)--数据的导入、导出及附件的查看处理

    http://www.cnblogs.com/wuhuacong/p/4777720.html 在很多系统模块里面,我们可能都需要进行一定的数据交换处理,也就是数据的导入或者导出操作,这样的批量处理能 ...