【连载】Maven系列(四)——配置私服
相关文章
一、为什么需要私服
有些公司并不提供外网给程序员,因此不能使用maven访问远程的仓库地址,所以很有必要在局域网里找一台有外网权限的机器;搭建nexus私服,然后程序员连到这台私服上,这样的话就可以通过这台搭建了nexus私服的电脑访问maven的远程仓库。
二、配置步骤
第一步:下载nexus-2.6.4-02.war包,然后拷贝到tomcat下的webapps目录中
http://www.sonatype.org/nexus/go Download the Nexus WAR distribution
第二步:启动tomcat
第三步:访问http://localhost:8088/nexus-2.6.4-02显示如下:
第四步:点击右上角“log in” ,输入username:admin 和Password:admin123登录
第五步:登录成功
第六步:点击Views/Repositories 中Repositories
Nexus内置仓库说明:
(1)Maven Central:该仓库代理Maven中央仓库,其策略为Release,因此只会下载和缓存中央仓库中的发布版本构件。
(2)Releases:这是一种策略为Release的宿主类型仓库,用来部署组织内部的发布版本构件。
(3)Snapshots:这是一个策略为Snapshot的宿主类型仓库,用来部署组织内部的快照版本构件。
(4)3rd party:这是一个策略为Release的宿主类型仓库,用来部署无法从公共仓库获得的第三方发布版本构件。
(5)Public Repositories:该仓库组将上述所有策略为Release的仓库聚合并通过一致的地址提供服务。
第七步:创建宿主目录和代理仓库
Hosted:本地仓库,通常我们会部署自己的构件到这一类型的仓库。 包括3rd party仓库,Releases仓库,Snapshots仓库
Proxy:代理仓库,它们被用来代理远程的公共仓库,如maven中央仓库。
Group:仓库组,用来合并多个hosted/proxy仓库,通常我们配置maven依赖仓库组。
第八步:创建仓库组
点击Public Repositories仓库,在Configurations栏中选取需要合并的仓库,点击箭头加到左边保存即可
第九步:下载Index索引并进行构建搜索(GAV搜索)
点击Views/Repositories菜单下面的Repositories,将这三个仓库 Apache Snapshots,Codehaus Snapshots,Central的Download Remote Indexes修改为 true。然后在这三个仓库上分别右键,选择Repari index,这样Nexus就会去下载远程的索引文件。
第十步:配置所有构建均从私服下载,在~/.m2/setting.xml中配置如下:
<settings>
<mirrors>
<mirror>
<!--此处配置所有的构建均从私有仓库中下载 *代表所有,也可以写central -->
<id>nexus</id>
<mirrorOf>*</mirrorOf>
<url>http://localhost:8088/nexus-2.6.4-02/content/groups/public</url>
</mirror>
</mirrors>
<profiles>
<profile>
<id>nexus</id>
<repositories>
<repository>
<id>nexus</id>
<name>local private nexus</name>
<url>http://localhost:8088/nexus-2.6.4-02/content/groups/public</url>
</repository>
</repositories>
</profile>
<profile>
<id>nexus-snapshots</id>
<repositories>
<repository>
<id>nexus-snapshots</id>
<name>local private nexus snapshots</name>
<url>http://localhost:8088/nexus-2.6.4-02/content/groups/public-snapshots</url>
</repository>
</repositories>
</profile>
</profiles>
<activeProfiles>
<!--make the profile active all the time -->
<activeProfile>nexus</activeProfile>
</activeProfiles>
第十一步:Nexus的访问权限控制,在~/m2/setting.xml中配置如下:
<!-- 设置发布时的用户名 -->
<servers>
<server>
<id> releases </id>
<username>admin</username>
<password>admin123</password>
</server>
<server>
<id> snapshots </id>
<username>admin</username>
<password>admin123</password>
</server>
</servers>
第十二步:
部署构建到Nexus,包含Release和Snapshot, 在项目根目录中pom.xml中配置:
<distributionManagement>
<repository>
<id>releases</id>
<name>Internal Releases</name>
<url>http://localhost:8088/nexus-2.6.4-02/content/repositories/releases/</url>
</repository>
<snapshotRepository>
<id>snapshots</id>
<name>Internal Snapshots</name>
<url>http://localhost:8088/nexus-2.6.4-02/content/repositories/snapshots/</url>
</snapshotRepository>
</distributionManagement>
第十三步:pom.xml
<distributionManagement>
<repository>
<id>releases</id>
<name>Internal Releases</name>
<url>http://localhost:8088/nexus-2.6.4-02/content/repositories/releases/</url>
</repository>
<snapshotRepository>
<id>snapshots</id>
<name>Internal Snapshots</name>
<url>http://localhost:8088/nexus-2.6.4-02/content/repositories/snapshots/</url>
</snapshotRepository>
</distributionManagement>
你还在等什么,赶快试试吧。
关注作者
【连载】Maven系列(四)——配置私服的更多相关文章
- 深入浅出Mybatis系列四-配置详解之typeAliases别名(mybatis源码篇)
注:本文转载自南轲梦 注:博主 Chloneda:个人博客 | 博客园 | Github | Gitee | 知乎 上篇文章<深入浅出Mybatis系列(三)---配置详解之properties ...
- Linux安装配置maven以及搭建nexus私服(编写启动脚本)
2011年07月12日16:32 下面介绍在Linux操作系统下安装配置maven和搭建nexus私服. 一.安装前的准备 下载 jdk http://www.oracle.com/technetw ...
- Maven系列(二) -- 将开源库上传到maven仓库私服
前言 之前简单说了下Maven的搭建,现在跟大家说一下如何将自己的aar传到我们新搭建的maven仓库里面,接下来我们就从最基本的新建一个library开始讲述整个流程,话不多说,让我们把愉快的开始吧 ...
- Maven第四篇【私有仓库、上传jar包、引用私服jar包、上传本地项目到私服】
搭建私有服务器 前面已经说过了,我们使用Maven的使用,如果需要导入相对应的jar包,Maven首先会在我们的本地仓库中寻找->私有仓库->中心仓库- 然而,我们的本地仓库常常没有想要的 ...
- Maven学习 四 Eclipse与Maven结合的配置
本问承接Maven学习 三 第一步:配置本地仓库 (1)默认配置 查看 本地仓库的位置是在一个叫做setting.xml的配置文件中设置,如果我们不配置,会使用开发工具自己集成的一个setting.x ...
- MyEclipse中引用的maven配置文件只访问私服的配置
MyEclipse中要用到集成的maven,公司内网有个私服,办公机不能上外网. 这时Eclipse中设置引用的外部Setting配置文件中只需如下配置即可: 1.配置本地主机的maven仓库路径 & ...
- maven 远程仓库、私服及镜像配置
maven仓库分类 本地仓库.远程仓库.远程仓库又有私服.中央仓库.其它公共库.中央仓库是maven自带的核心仓库. 仓库配置远程仓库可以配置多个,超级pom中定义的中央仓库 <reposito ...
- Hexo系列(四) NexT主题配置
Hexo 框架允许我们更换合适的主题,以便于构建不同风格的网站,这里介绍目前最常使用的一款主题之一 -- NexT 一.NexT 安装 在正式开始讲解 NexT 安装之前,我们必须明确以下几个概念: ...
- Maven(四)之Maven在IntelliJ IDEA的配置与使用
前面介绍了Maven的一些基本知识,这一篇讲一下在IntelliJ IDEA配置和使用Maven 一.配置Maven 在File->Settings->Build,Execution,De ...
随机推荐
- SQL SERVER 2012断日志
有一个SQL2012库的日志达到了100G左右,平时开发人员根本没有做过事务日志备份,而磁盘空间已经快满了.所以,只能截断它.但是,由于从2K8以后,SQL SERVER好像不再提供 truncate ...
- 使用TimeSpan对象获取时间间隔
实现效果: 关键知识: TimeSpan对象表是时间间隔或持续时间,两个DateTime对象相减,则会得到一个TimeSpan对象 使用其days ,hours,minutes等属性 实现代码: pr ...
- Golang Failpoint 的设计与实现
小结: 1. https://mp.weixin.qq.com/s/veIoupLjM4l5SUVC6h_Gkw Golang Failpoint 的设计与实现 原创: 龙恒 PingCAP 今天
- stn,spatial transformer network总结
对整篇paper的一个总结:https://blog.csdn.net/xbinworld/article/details/69049680 github:1.https://github.com/D ...
- D - Going Home POJ - 2195 网络流
On a grid map there are n little men and n houses. In each unit time, every little man can move one ...
- 【luogu P1262 间谍网络】 题解
题目链接:https://www.luogu.org/problemnew/show/P1262 注意: 1.缩点时计算出入度是在缩完点的图上用color计算.不要在原来的点上计算. 2.枚举出入度时 ...
- 【题解】UVA1218 Perfect Service
UVA1218:https://www.luogu.org/problemnew/show/UVA1218 刷紫书DP题ing 思路 参考lrj紫书 不喜勿喷 d(u,0):u是服务器,孩子是不是服务 ...
- 解密Spring加载的Properties文件
Spring的框架中,org.springframework.beans.factory.config.PropertyPlaceholderConfigurer类可以将.properties(key ...
- android ListView 与GridView 学习总结(五)
ListView的使用总结 基本使用: 步骤:在布局文件中定义一个ListView控件-在活动中获得ListView的实例-获得适配器adapter的实例并且传入三个参数-把适配器对象传递给lis ...
- jquery mobile 移动web(2)
button 按钮 data-role="button" 将超链接变成button. 具有icon 图标的button 组件. 提供了18常用的图标 data-icon =&quo ...