【连载】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 ...
随机推荐
- (第四场)F Beautiful Garden
题目: F Beautiful Garden 题目描述 There's a beautiful garden whose size is n x m in Chiaki's house. The ga ...
- 2018.10.31 Mac下的Mysql修改字符编码修改的问题总结
今天在弄数据库的时候发现存入中文汉字变成了问号,Mac跟windows处理方式不一样. show variables like '%char%'; 查看当前mysql的编码格式 也就是默认编码格式 + ...
- vue快速使用
1.引用脚本 <script src="https://cdn.jsdelivr.net/npm/vue@2.5.17/dist/vue.js"></script ...
- 【洛谷P3205】[HNOI2010]CHORUS 合唱队
合唱队 区间DP f[l][r][0/1]表示生成目标序列中的区间[l,r],最后一个数是a[l]/a[r] 的方案数 边界: f[i][i][0]=1 转移: f[l][r][0]=(a[l]< ...
- laravel5项目安装debugbar
链接:https://github.com/barryvdh/laravel-debugbar 1.项目目录运行 composer require barryvdh/laravel-debugbar ...
- CentOS 7安装Oracle (CentOS Linux release 7.5.1804)
从安装操作系统到完成oracle安装 1.安装centos7 下载CentOS7 iso安装包,配置虚拟机,由于只进行oracle安装练习,随便配置20G空间.选择安装文件. 开机,开始安装系统: 直 ...
- kindeditor简单使用
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"% ...
- vue项目中使用vuex
1.运行 cnpm i vuex -S 2.导入包 import Vuex from 'vuex' 3.注册vuex到vue中 Vue.use(vuex) 4. var store = new Vue ...
- 使用第三方工具连接docker数据库
一.背景 为了把测试环境迁移至docker上,我在centos7上安装了docker,具体安装方法可参考<CentOS7下安装docker>本文不再论述.有些同学可能会有疑问,为什么要 ...
- mysql 查询各个阶段所消耗的时间