nexus私服搭建

本文详细介绍了如何搭建Nexus私服,包括安装JDK、Maven和Nexus,以及配置Nexus和本地Maven settings.xml。通过Nexus管理公共包和私有包,移除maven-central成员,并设置了发布包和源码到私服的步骤。
摘要由CSDN通过智能技术生成

目标

公共包从阿里maven仓库获取
私有包由nexus私服管理
在这里插入图片描述

安装

  1. 安装JDK8
  2. 安装maven3
  3. 安装nexus
    下载
    https://help.sonatype.com/repomanager3/download?_ga=2.981497.977242279.1553142814-913108894.1552909009
    解压
    运行,以windows为例
    %nexus_home%\nexus-3.15.2-01\bin\nexus.exe /run
    访问
    http://localhost:8081/

配置

  1. 移除public group库中的maven-central成员
    在这里插入图片描述
    使用默认账号admin/admin123登录
    将maven-central从maven-public的成员列表中移除
  2. 设置本地的settings.xml
    1)在profiles中配置私服
		<profile>
			<id>dev</id>
			<repositories>
				<repository>
				  <id>nexus-local</id>
				  <url>http://localhost:8081/repository/maven-public/</url> 
				  <releases>
					<enabled>true</enabled>
				  </releases>
				  <snapshots>
					<enabled>true</enabled>
				  </snapshots>
				</repository>
			</repositories>
		</profile>

2)默认激活dev

    <activeProfiles>
        <activeProfile>dev</activeProfile>
    </activeProfiles>

3)配置mirror

		<mirror>    
		  <id>nexus-aliyun</id>  
		  <name>nexus-aliyun</name>
		  <url>http://maven.aliyun.com/nexus/content/groups/public</url>  
		  <mirrorOf>*,!nexus-local</mirrorOf>
		</mirror>
  1. 发布包和源码到私服
    1)settings.xml设置发布所用的用户名&密码
        <server>
            <id>releases</id>
            <username>admin</username>
            <password>admin123</password>
        </server>
        <server>
            <id>snapshots</id>
            <username>admin</username>
            <password>admin123</password>
        </server>

2)项目pom.xml中设置发布地址

	<distributionManagement>
		<repository>
			<id>releases</id>
			<name>Releases</name>
			<url>http://localhost:8081/repository/maven-releases/</url>
		</repository>
		<snapshotRepository>
			<id>snapshots</id>
			<name>Snapshot</name>
			<url>http://localhost:8081/repository/maven-snapshots/</url>
		</snapshotRepository>
	</distributionManagement>

3)项目pom.xml中新增打包源码插件

	<build>
		<plugins>
			<plugin>
				<artifactId>maven-source-plugin</artifactId>
				<executions>
					<execution>
						<id>attach-sources</id>
						<phase>verify</phase>
						<goals>
							<goal>jar-no-fork</goal>
						</goals>
					</execution>
				</executions>
			</plugin>
		</plugins>
	</build>

4)发布
在这里插入图片描述
5.结果
在这里插入图片描述

参考资料

[1]. maven nexus3.13 安装 —Windows服务器安装过程和基本使用
[2]. Maven系列二setting.xml 配置详解

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值