一、安装

1、从网上下载nexus软件
https://www.sonatype.com/download-oss-sonatype  下载Nexus Repository Manager OSS软件包
目前我使用的是3.0的版本,下面均是以安装3.0的版本位例子
2、将下载下来的nexus-3.13.0-01-win64.zip解压缩到目标路径,官网建议windows不要放在Program files 下,那么本人放在D:/develop下面
3、
(1) 未注册成系统服务,直接运行:
  a)进入bin目录,运行cmd 命令 :nexus.exe /run 此时运行私有仓库;linux版本可以执行:nexus /run
  b)按ctrl-c可以停止运行私服;
(2) 注册成系统服务(需要确保jdk已经在系统中安装过):
  a) 进入bin目录,运行cmd:nexus.exe /install  此时会安装私有仓库;
  b) 安装完成之后,默认访问端口未8081,上下文为 /
  c) 进入页面之后,直接登录,账号:admin  admin123
  d) 在访问的时候,请使用ip访问

4、关于Nexus Repository Manager 更多介绍 可参考网址:https://help.sonatype.com

二、配置

按照以上的方法搭建好私服之后,此时需要对私服里面的内容进行配置,用户通用浏览器(http://127.0.0.1:8001/)访问私服。

1、以管理员身份登入私服

在首页的右上角点击"Sign In" 进入登入页面,账号为:admin 密码为:admin123;

2、配置代理仓库

本地maven(已安装Maven软件)setting.xml 中在没有私服的情况下,需要配置各种代理或镜像(通过这些将需要的第三方提供的jar包下载到本地仓库供maven工程直接引用)。但是由于网速原因或在不同电脑项目中都需要连接网络通过镜像将所需jar包下载下来,一方面速度较慢,另一方面不好管理。因此需要私服,让setting.xml直接配置私服的仓库地址即可。

(1) 在私服中配置各种市面上常见的仓库地址(增加新的代理源)

  • 设置名称和URL

Cache统一设置为200天 288000

  • 逐个增加常用代理
1. aliyun
http://maven.aliyun.com/nexus/content/groups/public
2. apache_snapshot
https://repository.apache.org/content/repositories/snapshots/
3. apache_release
https://repository.apache.org/content/repositories/releases/
4. atlassian
https://maven.atlassian.com/content/repositories/atlassian-public/
5. central.maven.org
http://central.maven.org/maven2/
6. datanucleus
http://www.datanucleus.org/downloads/maven2
7. maven-central (安装后自带,仅需设置Cache有效期即可)
https://repo1.maven.org/maven2/
8. nexus.axiomalaska.com
http://nexus.axiomalaska.com/nexus/content/repositories/public
9. oss.sonatype.org
https://oss.sonatype.org/content/repositories/snapshots
10.pentaho
https://public.nexus.pentaho.org/content/groups/omni/
11. spring-snapshots
https://repo.spring.io/snapshot
//在配置这个代理源的时候,Version pollcy 要设置成 Snapshot,Layout pollcy 要设置成 Permissive.
12. spring-milestones
https://repo.spring.io/milestone

再次强调,在

How long (in minutes) to cache metadata before rechecking the remote repository.处

统一设置为

288000 即200天,当然可以设置为更长的时间

设置maven-public

  • 将这些代理加入Group

  • 设置私用仓库可重复发布

  Nexus安装后自带maven-releases,maven-snapshots两个仓库,用于将生成的jar包发布在这两个仓库中,在实际开发中需要将maven-releases设置为可以重复发布。

  maven-releases

  

  注:maven-snapshots缺省是可以重新部署的。

(2) 在maven的安装路径下conf/Setting.xml中配置如下内容:

<settings>
<pluginGroups>
<pluginGroup>org.sonatype.plugins</pluginGroup>
</pluginGroups>
<mirrors>
<mirror>
<id>nexus</id>
<mirrorOf>*</mirrorOf>
<url>http://localhost:8081/repository/maven-public/</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>
<servers>
<server>
<id>nexus</id>
<username>admin</username>
<password>admin123</password>
</server>
</servers>
</settings>

(3) 测试

将settings.xml中记录的maven仓库地址中的之前下载下来的jar包全部删除。在maven 工程右键 Maven ---> update product,在出来的弹出框中选择 "force update of snapshorts/releases",重新下载所需依赖的jar包即可。

PS:私服配置的内容参考了:https://www.cnblogs.com/fanzhenyong/p/7709434.html

最新文章

  1. 知乎大牛的关于JS解答
  2. iOS开发Swift篇(01) 变量&amp;常量&amp;元组
  3. android获取设备全部信息
  4. Delphi中如何将 Exe 程序或其他资料打包在内,使用时再释放使用(转)
  5. nginx - ssl 配置 - globelsign ssl
  6. Invalidate、RedrawWindow与UpdateWindow
  7. psp系统需求分析
  8. linux修改系统时间
  9. as 快捷键
  10. 关于 struts2 Unable to load configuration. - action
  11. 利用Eclipse中的Maven构建Web项目(一)
  12. ToastUtil【简单的Toast封装类】【未自定义Toast的显示风格】
  13. Java内存区域与内存溢出异常(JVM学习系列1)
  14. CSS背景和CSS列表
  15. Hive思维导图之Hive优化
  16. SpringBoot------连接MySQL报错:The server time zone value &#39;&#214;&#208;&#185;&#250;&#177;&#234;&#215;&#188;&#202;&#177;&#188;&#228;&#39; is unrecognized
  17. Monotonic Array LT896
  18. C#sealed和final
  19. (转)用graph-easy描绘kubenetes描绘k8s组件逻辑图
  20. 转:C#串口编程

热门文章

  1. 概念了解:CGI,FastCGI,PHP-CGI与PHP-FPM
  2. java 字符串内存分配的分析与总结
  3. 关于C51 keil使用中.c文件的链接心得
  4. white box白盒测试
  5. POJ 3318:Matrix Multiplication(随机算法)
  6. 玲珑OJ 1083:XJT Love Digits(离线处理+哈希)
  7. redis 基础数据结构实现
  8. spring boot freemarker 导出word 带echarts图形报表
  9. 2018年东北地区赛S - Problem I. Spell Boost HDU - 6508
  10. python通过TimedRotatingFileHandler按时间切割日志