nexus-3.9.0搭建maven私服
1.下载地址
https://sonatype-download.global.ssl.fastly.net/repository/repositoryManager/3/nexus-3.9.0-01-win64.zip
2.注册服务启动
找到目录下nexus-3.9.0-01\bin\nexus.exe cmd命令下执行 nexus.exe /run
类似参数(start, stop, restart, force-reload and status)
或者注册为系统服务 ,执行 nexus.exe /install <optional-service-name>
nexus.exe /start <optional-service-name>
nexus.exe /stop <optional-service-name>
nexus.exe /uninstall <optional-service-name>
3.建立你的maven仓库
3.1建立代理仓库
访问http://localhost:8081/
默认这个nexus创建好了一些仓库,我们统统删了
先建立一个代理maven仓库
最终类似
我代理的是:https://repo1.maven.org/maven2/
代理仓库:是指我们下载的文件会在私服上保存一份,第一下载到远程中央库(https://repo1.maven.org/maven2/)下载,第二次从我们的私服下载
3.2建立本地仓库(第三方我们自己的包库)
类型选择mave2(hosted)就可以了,之后填写名字就可以了
3.3 建立仓库组
选择mave2(group)
建立仓库组的好处就是我们只需要配置仓库组的地址给客户端,而不需要配置两个地址(一个本地,一个代理),就可以了
4.上传我们的第三方库文件
按要求填写groupid等等就可以了
5.你的maven配置文件setting.xml
<settings>
<mirrors>
<mirror>
<!--This sends everything else to /public -->
<id>nexus</id>
<mirrorOf>*</mirrorOf>
<url>http://192.168.100.163:8081/repository/maven-group/</url>
<!-- 这个地址就是我们仓库组的地址 --> </mirror>
</mirrors>
<profiles>
<profile>
<id>nexus</id>
<!--Enable snapshots for the built in central repo to direct -->
<!--all requests to nexus via the mirror -->
<repositories>
<repository>
<id>central</id>
<url>http://central</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<url>http://central</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
<activeProfiles>
<!--make the profile active all the time -->
<activeProfile>nexus</activeProfile>
</activeProfiles> < </settings> |
更多配置可以参考官方文档
https://help.sonatype.com/repomanager3/quick-start-guide-proxying-maven-and-npm