下载安装

首先我们需要下载解压压缩包:

(下载地址)

nexus 配置 maven加速 nexus搭建maven私有仓库_上传


假设我们的解压地址为:D:\maven\nexus-3.13.0-01-win64\nexus-3.13.0-01\bin注意: 一定要用管理员身份运行cmd

注意: 一定要用管理员身份运行cmd

注意: 一定要用管理员身份运行cmd

nexus 配置 maven加速 nexus搭建maven私有仓库_依赖库_02


这时候运行命令:nexus.exe/install

如果你不是以管理员身份运行的话,会出现这种情况

nexus 配置 maven加速 nexus搭建maven私有仓库_依赖库_03


当你以管理员身份运行,出现下面情况代表你按照成功了

nexus 配置 maven加速 nexus搭建maven私有仓库_nexus 配置 maven加速_04

开启服务,登陆仓库管理地址

1,运行nexus.exe/start

nexus 配置 maven加速 nexus搭建maven私有仓库_上传_05

稍微等待几秒钟,在网址中输入localhost:8081或者你的ip地址:8081就可以进入仓库管理页面,登陆前

nexus 配置 maven加速 nexus搭建maven私有仓库_上传_06


账号密码默认是: 账号: admin 密码:admin123 当然你登陆成功后可以自己修改,这是登陆后

nexus 配置 maven加速 nexus搭建maven私有仓库_maven_07

创建自己的maven库

nexus 配置 maven加速 nexus搭建maven私有仓库_上传_08


我们可以看到maven有三种类型,其中hosted创建最简单,其中它们三个的区别和创建方法大家自行去谷歌哈 ,这里我就讲最快捷的创建方式

nexus 配置 maven加速 nexus搭建maven私有仓库_nexus 配置 maven加速_09


然后我们可以看到创建仓库页面

nexus 配置 maven加速 nexus搭建maven私有仓库_nexus 配置 maven加速_10


输入完你的仓库名称,点击创建,然后可以看到我们的仓库创建完成了

nexus 配置 maven加速 nexus搭建maven私有仓库_依赖库_11


这时候我们点击进去,可以看到我们创建的仓库信息

nexus 配置 maven加速 nexus搭建maven私有仓库_依赖库_12


现在我们的远程依赖仓库创建完成了, 可以将我们的依赖包发布到仓库了

将依赖库发布到仓库

我们首先要在Android studio创建一个依赖库

nexus 配置 maven加速 nexus搭建maven私有仓库_上传_13

创建完成后我们需要在gradle.properties文件中配置仓库地址、账号密码、依赖库的版本名称以及版本号等信息
我用的是我之前创建仓库地址,所以不用纠结,你配置你自己刚才创建的maven仓库地址就OK了

nexus 配置 maven加速 nexus搭建maven私有仓库_上传_14

然后我们需要在Project的gradle下配置仓库地址

nexus 配置 maven加速 nexus搭建maven私有仓库_依赖库_15

最后我们需要在依赖库的gradle下配置依赖库信息

nexus 配置 maven加速 nexus搭建maven私有仓库_nexus 配置 maven加速_16

编译一下,上传我们的依赖库到maven仓库

nexus 配置 maven加速 nexus搭建maven私有仓库_maven_17

上传成功后,我们可以在我们创建的仓库里面看到我们上传的依赖库

nexus 配置 maven加速 nexus搭建maven私有仓库_依赖库_18

这个时候我们在我们的主项目gradle里添加依赖库版本编译一下就ok了

nexus 配置 maven加速 nexus搭建maven私有仓库_maven_19

如果你上传错了,你可以删除掉你上传的依赖库

nexus 配置 maven加速 nexus搭建maven私有仓库_上传_20

当你不需要上传到maven库时,记得将服务停止了

nexus 配置 maven加速 nexus搭建maven私有仓库_依赖库_21


下次在需要上传时,不需要重新安装,只需要start就ok了,有什么问题可以在下面留言哦