Windows10搭建Maven私服3.19.1+添加阿里云中央服务器 + 私服使用配置[二]

Windows10搭建Maven私服3.19.1+添加阿里云中央服务器 + 私服使用配置[二]

(一) 前期准备

没有搭建本地私服的可以先查阅前置教程:Windows10搭建Maven私服3.19.1+添加阿里云中央服务器 + 私服使用配置[一]

(二) 添加阿里云中央服务器

1.登陆私服,进入私服的 管理界面->Repositories 进入仓库管理页面

(在这里点击copy按钮就能获得对应仓库的url,放到配置文件中即可使用,但是选用哪个仓库需要自己去选择)
在这里插入图片描述

2.常用Maven仓库类型介绍

2.1. 聚合仓库 [maven2(group)]
将多个宿主仓库聚合到同一个group中,使用中统一指定聚合仓库的仓库地址可以获取到同一group下的所 有包,免去多仓库多地址的配置繁琐。聚合仓库的聚合成员可以在仓库设置中添加和移除
2.2.宿主仓库 [maven2(hosts)]
平常使用的仓库,不多说明。需要注意的是宿主仓库有两种日常开发可以使用到的类型。
(2.2.1).release
release 仓库不能重复上传同一版本号,版本不能覆盖,只能迭代,所以开发的稳定版本可以统一放置在 release仓库中在这里插入图片描述
(2.2.2).snapshot
snapshot 仓库允许版本覆盖,当多次上传同一个版本到 snapshot 仓库,会自动在版本号上添加时间戳来区分。建议在开发测试时使用。
在这里插入图片描述
2.3.远程代理仓库[maven2(proxy)]
这种类型的仓库,可以设置一个远程仓库的链接。当用户向 proxy 类型仓库请求下载一个依赖构件时,就会先在自己的库里查找,如果找不到的话,就会从设置的远程仓库下载到自己的库里,然后返回给用户,相当于起到一个中转的作用。(今天要添加的阿里云中央仓库就是一个远程代理仓库)

3.添加阿里云中央仓库

3.1点击仓库管理页面的 create repository 按钮添加仓库
在这里插入图片描述
选择maven2(proxy)
在这里插入图片描述
填写对应的配置信息
Version pollcy:Release
Remote storage:http://maven.aliyun.com/nexus/content/groups/public/(阿里云中央仓库地址)
在这里插入图片描述
点击保存返回仓库管理页面查看这样就成功在私服中添加了阿里云仓库
在这里插入图片描述

(三) 私服使用配置

以下是我自己的一个使用maven私服服务器的配置文件,需要将关键位置信息修改为自己的

<?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>yourUsername</username>
		<password>yourPassword</password>
	</server>
	<server>
		<id>nexus_wyc</id>
		<username>yourUsername</username>
		<password>yourPassword</password>
	</server>
	<server>
		<id>releases</id>
		<username>yourUsername</username>
		<password>yourPassword</password>
	</server>
	<server>
		<id>snapshots</id>
		<username>yourUsername</username>
		<password>yourPassword</password>
	</server>
	<server>
		<id>pubilc</id>
		<username>yourUsername</username>
		<password>yourPassword</password>
	</server>
  </servers>

  
  <mirrors>
	 <!-- 使用自己的maven私服服务器 -->
	 <mirror>
	   <id>nexus</id>
	   <mirrorOf>nexus</mirrorOf>
	   <name>my nexus</name>
	   <url>你的maven私服仓库地址</url>
	 </mirror>
  </mirrors>

 
  <profiles>
	<profile>
		<!-- dev配置 -->
		<id>dev</id>
		<repositories>
		    <!-- 配置nexus远程仓库 -->
		    <repository>
		        <id>nexus</id>
		        <name>Nexus Snapshot Repository</name>
		        <url>你的maven私服仓库地址</url>
		        <releases>
		            <enabled>true</enabled>
		        </releases>
		        <snapshots>
		            <enabled>false</enabled>
		        </snapshots>
		    </repository>
		</repositories>
		<pluginRepositories>
			<pluginRepository>
				<id>public</id>
				<name>Public Repository</name>
				<url>你的maven私服仓库地址</url>
			</pluginRepository>
		</pluginRepositories>
	</profile>
  </profiles>
  <!-- 启用dev配置 -->
  <activeProfiles>
    <activeProfile>dev</activeProfile>
  </activeProfiles>
</settings>

好啦,到这里maven私服搭建和使用的教程就算完啦,有疑问的可以下方评论,看到过后我都会尽力帮助大家解答,如有不足也可以提出来大家相互学习,一起进步!

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值