环境
  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 本地仓库路径

  1. <localRepository>E:\repository</localRepository>

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

  1. <!--指定Nexus的构件仓库-->
  2. <repositories>
  3. <repository>
  4. <id>public</id>
  5. <name>Team Maven Repository</name>
  6. <url>http://134.32.123.103:8081/nexus/content/groups/public/</url>
  7. <releases>
  8. <enabled>true</enabled>
  9. </releases>
  10. <snapshots>
  11. <enabled>true</enabled>
  12. </snapshots>
  13. </repository>
  14. </repositories>
  15.  
  16. <!--指定Nexus的插件仓库-->
  17. <pluginRepositories>
  18. <pluginRepository>
  19. <id>public</id>
  20. <name>Team Maven Repository</name>
  21. <url>http://134.32.123.103:8081/nexus/content/groups/public/</url>
  22. <releases>
  23. <enabled>true</enabled>
  24. </releases>
  25. <snapshots>
  26. <enabled>true</enabled>
  27. </snapshots>
  28. </pluginRepository>
  29. </pluginRepositories>

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

  1. <profiles>
  2. <profile>
  3. <id>myprofile</id>
  4. <repositories>
  5. <repository>
  6. <id>central</id>
  7. <url>http://central</url>
  8. <releases>
  9. <enabled>true</enabled>
  10. </releases>
  11. <snapshots>
  12. <enabled>true</enabled>
  13. </snapshots>
  14. </repository>
  15. </repositories>
  16. <pluginRepositories>
  17. <pluginRepository>
  18. <id>central</id>
  19. <url>http://central</url>
  20. <releases>
  21. <enabled>true</enabled>
  22. </releases>
  23. <snapshots>
  24. <enabled>false</enabled>
  25. </snapshots>
  26. </pluginRepository>
  27. </pluginRepositories>
  28. </profile>
  29. </profiles>

(2)激活profile

  1. <activeProfiles>
  2. <activeProfile>myprofile</activeProfile>
  3. </activeProfiles>

(3)配置镜像

  1. <mirrors>
  2. <mirror>
  3. <id>nexus</id>
  4. <url>http://127.0.0.1:7788/nexus/content/groups/public/</url>
  5. <mirrorOf>*</mirrorOf>
  6. </mirror>
  7. </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. redmine创建新闻,自动发邮件给项目组所有成员

    redmine创建新闻,自动发邮件给项目组所有成员: 1.添加用户至公共项目内 2.配置系统邮件推送配置 3.检查用户接受推送配置 3.使用管理员账户发布新闻(不能自己发送自己) 4.查看邮件接受邮件

  2. 【CF913F】Strongly Connected Tournament 概率神题

    [CF913F]Strongly Connected Tournament 题意:有n个人进行如下锦标赛: 1.所有人都和所有其他的人进行一场比赛,其中标号为i的人打赢标号为j的人(i<j)的概 ...

  3. Mongodb高级篇-性能优化

    1.监控 mongodb可以通过profile来监控数据,进行优化. 查看当前是否开启profile功能用命令:db.getProfilingLevel()返回level等级,值为0|1|2,分别代表 ...

  4. Ubuntu16.04 安装lamp环境

    拿到新装的ubuntu16.04新系统 首先 apt-get update 更新一下 我这里是root用户,如果您不是超级管理员,命令前加sudo即可 如果您加了sudo也不好使,那就联系管理员,给你 ...

  5. python----并发之协程

    <python并发之协程>一: 单线程下实现并发,即只在一个主线程,并且cpu只有一个的情况下实现并发.(并发的本质:切换+保存状态) cpu正在运行一个任务,会在两种情况下切去执行其他的 ...

  6. HDU-4539郑厂长系列故事——排兵布阵(状态压缩,动态规划)

    郑厂长系列故事--排兵布阵 Time Limit : 10000/5000ms (Java/Other) Memory Limit : 65535/32768K (Java/Other) Total ...

  7. MapRedece(单表关联)

    源数据:Child--Parent表 Tom Lucy Tom Jack Jone Lucy Jone Jack Lucy Marry Lucy Ben Jack Alice Jack Jesse T ...

  8. 蓝桥杯 - 数字排列(今有7对数字) - [两种不同的DFS思路]

    今有7对数字:两个1,两个2,两个3,...两个7,把它们排成一行.要求,两个1间有1个其它数字,两个2间有2个其它数字,以此类推,两个7之间有7个其它数字.如下就是一个符合要求的排列: 171264 ...

  9. POJ - 1101 The Game dfs

    题意:给你一个地图,上面有一些‘X',给你起点终点,让你输出从起点到终点的路径中转向(改变方向)次数最少的路径,注意,不能穿过别的’X'并且可以超过边界 题解:关于超过边界,只要在外围多加一圈‘ ’. ...

  10. Dungeon Master---2251(bfs)

    http://poj.org/problem?id=2251 有一个三维的牢房地图 求从S点走E点的最小时间: #include<stdio.h> #include<string.h ...