nexus2.x搭建maven私服教程(windows环境)

nexus2.x搭建maven私服教程(windows环境)

 

nexus

  1. 下载
    官网地址https://www.sonatype.com/download-oss-sonatype
    我下载的版本是nexus-2.14.4-03-bundle.tar.gz
  2. 解压
    解压后有两个文件夹如下
  3. 安装启动
    双击nexus-2.14.4-03,双击bin,双击jsw如下
    这里写图片描述
    这里是各种环境的安装方式,大家请自行选择。我选择的是windows-x86-32
    这里写图片描述
    console-nexus:启动nexus并在cmd中展示启动过程。
    install-nexus:将nexus设置成windows服务,开机自动启动。
    start-nexus:启动nexus。
    stops-nexus:停止nexus。
    uninstall-nexus:没用过字面意思应该是卸载暂时不使用。
    第一次启动选择前3个都可以看自己需求。为方便启动和退出Nexus,可将bin目录添加到环境变量path中。(如果不会配置环境变量请自行百度)配好环境变量后在cmd中键入nexus可以查看相应命令。键入nexus 命令(nexus start) 即可。
    nexus2.6以后至少要求安装jdk1.7以上才能正常启动
    这里写图片描述
    启动成功后,打开localhost:8081/nexus,进入如下页面
    这里写图片描述
    点击右上角login登陆,默认账号密码 admin/admin123,后面可根据需求自行修改。
  4. 从中央库下载索引到私服中央库
    依次点击1.左边的Repositories 2.点击Central 3.点击下面的Configuration 4.找到Download Remote Indexes 5.选择true 6.右键Central选择repair index或者update index都行
    这里写图片描述
    至此私服就开始向中央库下载更新索引了(前提你要有网络,否则会失败)
    点击左边的Administration下的Scheduled Tasks可以查看当前任务进度。如果状态为running则标示任务已经开始执行。
    这里写图片描述
    更新索引会花费比较多的时间大概半小时到1小时左右。
    如果想看进度可以打开nexus-2.14.4-03文件夹->logs->wapper.log查看日志。
    这里写图片描述
    如果日志中出现
    jvm 1 | 2017-07-21 15:48:19,615+0800 INFO [pxpool-1-thread-1] admin org.sonatype.nexus.index.NexusScanningListener - Scanning of repositoryID="central" started.
    标示更新索引已经开始。如果之后再没有信息表示正在进行。如果更新失败log里也会显示。如果显示finished则表示更新索引成功。
    jvm 1 | 2017-07-21 15:53:18,583+0800 INFO [pxpool-1-thread-1] admin org.sonatype.nexus.index.NexusScanningListener - Scanning of repositoryID="central" finished
    到这里,maven的私服算是搭建完成了。

maven

  1. 下载
    官网地址http://maven.apache.org/download.cgi
    我下载的是版本是apache-maven-3.3.9-bin.zip
    这里写图片描述
  2. 解压
    解压后只有一个文件夹如下
    这里写图片描述
  3. 配置环境变量
    点击apache-maven-3.3.9文件夹->bin,复制目录,将该目录配置到环境变量path中即可。
    这里写图片描述
    当然,安装的前提是要安装了jdk。
  4. 验证是否安装成功
    打开cmd 输入mvn -v 信息如下则表示安装成功。
    这里写图片描述

将maven指向nexus私服

依次打开apache-maven-3.3.9->conf->settings.xml
添加服务验证

<server>
    <id>nexus</id>
    <username>admin</username>
    <password>admin123</password>
</server>
  • 1
  • 2
  • 3
  • 4
  • 5

添加镜像

<mirror>   
        <id>nexus-mirror</id>   
        <mirrorOf>maven-central</mirrorOf>   
        <url>http://192.168.2.190:8081/nexus/content/repositories/central/</url>   
</mirror>
  • 1
  • 2
  • 3
  • 4
  • 5

做构件的配置

<profile>
      <id>nexuesProfile</id>
      <repositories>
          <repository>
              <id>maven-central</id>
              <name>maven-central</name>
              <url>http://192.168.2.190:8081/nexus/content/repositories/central/</url>
              <snapshots>
                  <enabled>true</enabled>
              </snapshots>
              <releases>
                  <enabled>true</enabled>
              </releases>
          </repository>
      </repositories>
</profile>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16

激活构件

<activeProfiles>
      <activeProfile>nexuesProfile</activeProfile>
 </activeProfiles>
  • 1
  • 2
  • 3

至此大功告成

下面贴上完整的settings.xml代码

<?xml version="1.0" encoding="UTF-8"?>

<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">

  <pluginGroups>
  </pluginGroups>

  <proxies>
  </proxies>

  <servers>
    <server>
      <id>nexus</id>
      <username>admin</username>
      <password>admin123</password>
    </server>
  </servers>

  <mirrors>
    <mirror>   
       <id>nexus-mirror</id>   
       <mirrorOf>maven-central</mirrorOf>   
       <url>http://192.168.2.190:8081/nexus/content/repositories/central/</url>   
    </mirror>  
  </mirrors>

  <profiles>
    <profile>
      <id>nexuesProfile</id>
      <repositories>
        <repository>
          <id>maven-central</id>
          <name>maven-central</name>
          <url>http://192.168.2.190:8081/nexus/content/repositories/central/</url>
          <snapshots>
              <enabled>true</enabled>
          </snapshots>
          <releases>
              <enabled>true</enabled>
          </releases>
        </repository>
      </repositories>
    </profile>
  </profiles>
  <activeProfiles>
    <activeProfile>nexuesProfile</activeProfile>
  </activeProfiles>

</settings>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52

关于settings.xml的详细介绍请移步http://blog.csdn.net/Dynamic_W/article/details/77483311

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值