nexus3.3.2配置使用(mac版)

###安装配置
1:下载nexus(http://www.sonatype.com/download-oss-sonatype) 最新版本3.3.2
2:解压下载文件,这里我放在了/Users/software/nexus-3.3.2-02-mac 目录。
3: 执行启动命令
/Users/software/nexus-3.3.2-02-mac/nexus-3.3.2-02/bin/nexus start

###更新maven-central中央仓库代理的索引
待解决,无法正常下载中央仓库索引到本地,待完善学习
报错信息如下:

2017-07-02 00:14:22,930+0800 WARN  [elasticsearch[49939698-7529D7C9-B2CB39D3-49474F42-51ACB25B][management][T#1]] *SYSTEM org.elasticsearch.cluster.routing.allocation.decider - [49939698-7529D7C9-B2CB39D3-49474F42-51ACB25B] high disk watermark [90%] exceeded on [Rs9VhAlmRuio8BSYI8VJXQ][49939698-7529D7C9-B2CB39D3-49474F42-51ACB25B][/Users/software/nexus-3.3.2-02-mac/sonatype-work/nexus3/elasticsearch/nexus/nodes/0] free: 17gb[7.3%], shards will be relocated away from this node
2017-07-02 00:14:22,931+0800 INFO  [elasticsearch[49939698-7529D7C9-B2CB39D3-49474F42-51ACB25B][management][T#1]] *SYSTEM org.elasticsearch.cluster.routing.allocation.decider - [49939698-7529D7C9-B2CB39D3-49474F42-51ACB25B] rerouting shards: [high disk watermark exceeded on one or more nodes]

###上传jar包至私服

####1、配置项目pom.xml文件

    <!-- 上传jar包到私服 -->
	<distributionManagement>
		<!-- 两个ID必须与 setting.xml中的<server><id>nexus-releases</id></server>保持一致 -->
		<repository>
			<id>nexus-releases</id>
			<name>Nexus Release Repository</name>
			<url>http://127.0.0.1:8081/repository/maven-releases/</url>
		</repository>
		
		<snapshotRepository>
			<id>nexus-snapshots</id>
			<name>Nexus Snapshot Repository</name>
			<url>http://127.0.0.1:8081/repository/maven-snapshots/</url>
		</snapshotRepository>
	</distributionManagement>

####2、修改maven settings.xml文件
添加server节点

    <server>  
      <id>nexus-releases</id>  
      <username>admin</username>  
      <password>admin123</password>  
    </server>  
   <server>  
      <id>nexus-snapshots</id>  
      <username>admin</username>  
      <password>admin123</password>  
   </server> 

添加镜像地址

    <mirror>
      <id>nexus</id>
      <mirrorOf>nexus-snapshots</mirrorOf>
      <url>http://127.0.0.1:8081/repository/maven-public/</url>
    </mirror>

添加profiles

<profiles>
    <profile>    
       <id>nexus</id>    
       <repositories>    
         <repository>    
           <id>nexus-releases</id>    
           <url>http://127.0.0.1:8081/repository/maven-releases</url>    
           <releases><enabled>true</enabled></releases>    
           <snapshots><enabled>true</enabled></snapshots>    
         </repository>    
         <repository>    
           <id>nexus-snapshots</id>    
           <url>http://127.0.0.1:8081/repository/maven-snapshots</url> 
           <releases><enabled>true</enabled></releases>    
           <snapshots><enabled>true</enabled></snapshots>    
         </repository>    
       </repositories>    
       <pluginRepositories>    
          <pluginRepository>    
                  <id>nexus-releases</id>    
                  <url>http://127.0.0.1:8081/repository/maven-releases</url>    
                  <releases><enabled>true</enabled></releases>    
                  <snapshots><enabled>true</enabled></snapshots>    
                </pluginRepository>    
                <pluginRepository>    
                  <id>nexus-snapshots</id>   
                  <url>http://127.0.0.1:8081/repository/maven-snapshots</url>      
                  <releases><enabled>true</enabled></releases>    
                  <snapshots><enabled>true</enabled></snapshots>    
                </pluginRepository>    
          </pluginRepositories>    
     </profile>
  </profiles>

  <!--nexus添加-->
  <activeProfiles>
    <activeProfile>nexus</activeProfile>
  </activeProfiles>

在项目下执行部署命令

mvn package
mvn deploy -X

这里写图片描述

###引用私服上的项目jar包
####1、配置项目pom.xml文件

  <repositories>
		<repository>
		   <id>nexus-snapshots</id>
		   <name>nexus Snapshots</name>
		   <url>http://127.0.0.1:8081/repository/maven-snapshots</url>
		</repository>         	  
  </repositories>

####2、配置maven settings.xml文件

     <mirror>
      <id>nexus</id>
      <mirrorOf>nexus-snapshots</mirrorOf>
      <url>http://127.0.0.1:8081/repository/maven-public/</url>
    </mirror>

或者

 <mirror>
      <id>nexus</id>
      <mirrorOf>*</mirrorOf>
      <url>http://127.0.0.1:8081/repository/maven-public/</url>
    </mirror>

####2、运行效果
这里写图片描述

这里写图片描述

####settings.xml mirror标签介绍
定义一个镜像库,至少需要提供如下三个参数:
首先是镜像库的id,用以唯一标识该镜像库,默认default
其次是镜像库的url,即该镜像库我访问位置
最后,也是最重要的,是要镜像的远程库。例如,如果要镜像Maven的central库,则设置

<mirrorOf>central</mirrorOf>

###错误

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project nexusRain: Failed to deploy artifacts: Could not transfer artifact com.maven.nexusRain:nexusRain:jar:0.0.1-20170702.022115-1 from/to nexus-snapshots (http://127.0.0.1:8081/repository/maven-snapshots/): Failed to transfer file: http://127.0.0.1:8081/repository/maven-snapshots/com/maven/nexusRain/nexusRain/0.0.1-SNAPSHOT/nexusRain-0.0.1-20170702.022115-1.jar. Return code is: 401, ReasonPhrase: Unauthorized. -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project nexusRain: Failed to deploy artifacts: Could not transfer artifact com.maven.nexusRain:nexusRain:jar:0.0.1-20170702.022115-1 from/to nexus-snapshots (http://127.0.0.1:8081/repository/maven-snapshots/): Failed to transfer file: http://127.0.0.1:8081/repository/maven-snapshots/com/maven/nexusRain/nexusRain/0.0.1-SNAPSHOT/nexusRain-0.0.1-20170702.022115-1.jar. Return code is: 401, ReasonPhrase: Unauthorized.

没有在setting.xml中配置相应的server

    <server>  
      <id>nexus-releases</id>  
      <username>admin</username>  
      <password>admin123</password>  
    </server> 

需要与项目pom.xml中的repositories.repository.id名称一致

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值