环境
  Red Hat Enterprise Linux Server release 7.3 (Maipo)
  jdk1.7.0_80
  apache-tomcat-7.0.90
  mysql-5.7.23  
  apache-maven-3.5.4
  nexus-2.11.1-01

1、Nexus的仓库类型分为以下四种:
group(仓库组):一组仓库的集合
hosted(宿主):配置第三方仓库 (包括公司内部私服 )
proxy(代理):私服会对中央仓库进行代理,用户连接私服,私服自动去中央仓库下载jar包或者插件
virtual(虚拟):兼容Maven1 版本的jar或者插件

Public Repositories: 仓库组
3rd party: 无法从公共仓库获得的第三方发布版本的构件仓库
Apache Snapshots: 用了代理ApacheMaven仓库快照版本的构件仓库
Central: 用来代理maven中央仓库中发布版本构件的仓库
Central M1 shadow: 用于提供中央仓库中M1格式的发布版本的构件镜像仓库
Codehaus Snapshots: 用来代理CodehausMaven 仓库的快照版本构件的仓库
Releases: 用来部署管理内部的发布版本构件的宿主类型仓库
Snapshots:用来部署管理内部的快照版本构件的宿主类型仓库

2、常用设置
点击右上角的 Log In 按钮即可登陆了。默认登录账号/密码为: admin/admin123 ,登陆成功后的界面

点击Repositories,将列表中所有Type为proxy 的项目的 Configuration 中的 Download Remote Indexes 设置为True

将Releases仓库的Deployment Policy设置为 Allow ReDeploy

当然我们也避免不了会使用到一些第三方的 jar ,而这些jar包也不存在于互联网上的maven中央仓库中,这时我们可以手工添加jar 到我们的私服中。
添加第三方 jar:

3、配置本地项目发布到Nexus
3.1在本地项目pom.xml中添加部署配置
<distributionManagement>
<repository>
<id>releases</id><!--这个ID需要与你的release仓库的Repository ID一致-->
<url>http://192.168.1.11:8081/nexus/content/repositories/releases</url>
</repository>
<snapshotRepository>
<id>snapshots</id><!--这个ID需要与你的snapshots仓库的Repository ID一致-->
<url>http://192.168.1.11:8081/nexus/content/repositories/snapshots</url>
</snapshotRepository>
</distributionManagement>

3.2在本地$MAVEN_HOME\conf目录下的settings.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>

在本地工程目录下执行:mvn clean deploy

所部署的包就自动上传到了nexus安装目录下的

4、配置Maven从Nexus下载构件
4.1 配置maven 本地仓库路径

<localRepository>E:\repository</localRepository>

4.2 在项目POM中配置Nexus私服,这样的配置只对当前的Maven项目有效。

<!--指定Nexus的构件仓库-->
<repositories>
<repository>
<id>public</id>
<name>Team Maven Repository</name>
<url>http://134.32.123.103:8081/nexus/content/groups/public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories> <!--指定Nexus的插件仓库-->
<pluginRepositories>
<pluginRepository>
<id>public</id>
<name>Team Maven Repository</name>
<url>http://134.32.123.103:8081/nexus/content/groups/public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>

4.3在maven settings.xml中配置profile元素,这样就能让本机所有的Maven项目都使用自己的Maven私服。
(1) maven提供了profile来配置仓库信息

<profiles>
<profile>
<id>myprofile</id>
<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>false</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>

(2)激活profile

<activeProfiles>
<activeProfile>myprofile</activeProfile>
</activeProfiles>

(3)配置镜像

<mirrors>
<mirror>
<id>nexus</id>
<url>http://127.0.0.1:7788/nexus/content/groups/public/</url>
<mirrorOf>*</mirrorOf>
</mirror>
</mirrors>

这里配置mirrorOf的值为*,代表maven的所有访问请求都会指向到Nexus仓库组。

参考:
maven全局配置文件settings.xml详解
Maven Nexus
Linux 使用nexus搭建maven私服

持续集成之三:Maven私服Nexus使用的更多相关文章

  1. 有手就行3——持续集成环境—maven、tomcat、安装和配置

    有手就行3--持续集成环境-maven.tomcat.安装 持续集成环境(5)-Maven安装和配置 持续集成环境(6)-Tomcat安装和配置 持续集成环境(5)-Maven安装和配置 在Jenki ...

  2. Maven私服Nexus的搭建

    # Maven私服Nexus的搭建 ## 私服存在的合理性 Maven中的依赖是从服务器仓库中下载的,Maven的仓库只有两大类: - 1) 本地仓库 - 2) 远程仓库,其中在远程仓库中又分成了3种 ...

  3. Centos 基础开发环境搭建之Maven私服nexus

    hmaster 安装nexus及启动方式 /usr/local/nexus-2.6.3-01/bin ./nexus status Centos 基础开发环境搭建之Maven私服nexus . 软件  ...

  4. Ubuntu server下搭建Maven私服Nexus

    Ubuntu server下搭建Maven私服Nexus Maven私服Nexus的作用,主要是为了节省资源,在内部作为maven开发资源共享服务器来使用. 1.下载 通过root用户进去Ubuntu ...

  5. maven私服nexus安装

    maven私服nexus安装 1.nexus特性 1.1.nexus私服实际上是一个javaEE的web 系统 1.2.作用:用来管理一个公司所有的jar包,实现项目jar包的版本统一 1.3.jar ...

  6. 持续集成之三:搭建Maven私服Nexus

    安装环境 Red Hat Enterprise Linux Server release 7.3 (Maipo) jdk1.7.0_80 apache-tomcat-7.0.90 mysql-5.7. ...

  7. 剑指架构师系列-持续集成之Maven+Nexus+Jenkins+git+Spring boot

    1.Nexus与Maven 先说一下这个Maven是什么呢?大家都知道,Java社区发展的非常强大,封装各种功能的Jar包满天飞,那么如何才能方便的引入我们项目,为我所用呢?答案就是Maven,只需要 ...

  8. maven私服nexus搭建(windows)

    1.下载nexus 地址:https://www.sonatype.com/download-oss-sonatype 下载相应版本的zip包. 2.安装nexus 下载完成后,解压到本地任意目录. ...

  9. maven私服nexus清理释放磁盘空间

    应用背景: 自建的maven私服(或者叫私仓)nexus在使用过程中,因很多服务不断迭代更新上传jar包至nexus中,底层存放在一个叫Blob Stores的存储中,最近发现该存储已增大至好几百G, ...

随机推荐

  1. 美团开源 SQL 优化工具 SQLAdvisor

    https://www.oschina.net/news/82725/sqladvisor-opensource https://github.com/Meituan-Dianping/SQLAdvi ...

  2. 设置ubuntu默认中文字符

    一. Ubuntu默认的中文字符编码 Ubuntu默认的中文字符编码为zh_CN.UTF-8,这个可以在 /etc/environment中看到:sudo gedit /etc/environment ...

  3. TFS二次开发04——工作区(Workspace)和映射(Mapping)

    在前面几节介绍了怎样读取TFS服务器上的项目以及文件的信息,这一节将介绍怎么建立服务器和本地的映射(Mapping). 引用命名空间 usingMicrosoft.TeamFoundation.Cli ...

  4. easyui datagrid 加载 历险记(dom中已经加载,fit:true 时改变浏览器大小是会显示出来)

    (dom中已经加载,fit:true 时改变浏览器大小是会显示出来) 第一个想到的就是resize datagird  大小!可是没有用 ... 答案是加载的的div height为0导至的(//To ...

  5. CSU1129 送货到家 【状压dp】

    哈哈发现这道题竟然没有题解,于是我决定写一份! 状压dp 题目: 懒惰的巫女Reimu因为各种原因在香霖堂的店主Rinnosuke那儿欠下了很多债,于是乎只好靠帮他在幻想乡中送货来偿还掉微不足道的一小 ...

  6. Pandas新建一个DataFrame

    我们在使用Pandas时候,前提需要一个新的DataFrame,需要首先初始化一个: 那么可以根据字典形式初始化: # 新建一个dataFrame df = pd.DataFrame({']) 必须包 ...

  7. 完整的Jquery-easyUI显示分页数据例子

    虽然说是入门的例子,但本人尽量做的详细点,以后会继续更新,部分功能 此外,为了后继easyui的学习,做了一个简单的框架:后台采用hibernate2.5+struts2开发:数据库用mysql.红色 ...

  8. ionic 相关问题解决办法记录

    1.npm无法安装模块 报code E400错误 解决办法: 删除npmrc文件. 注意:不是nodejs安装目录npm模块下的那个npmrc文件,而是在C:\Users\{账户}\下的.npmrc文 ...

  9. hmm前后向算法

    跟医生就医推导过程是一样的 隐马尔科夫模型HMM(一)HMM模型 隐马尔科夫模型HMM(二)前向后向算法评估观察序列概率 隐马尔科夫模型HMM(三)鲍姆-韦尔奇算法求解HMM参数 隐马尔科夫模型HMM ...

  10. python 线程,GIL 和 ctypes(转)

    原文:http://zhuoqiang.me/python-thread-gil-and-ctypes.html GIL 与 Python 线程的纠葛 GIL 是什么东西?它对我们的 python 程 ...