maven nexus私服搭建

访问nexus3官方镜像库,选择需要的版本下载:Docker Nexus

docker pull sonatype/nexus3:3.49.0

创建数据目录并赋权

sudo mkdir /nexus-data && sudo chown -R 200 /nexus-data

运行(数据目录选择硬盘大的卷进行挂载)

docker run -d -p 8081:8081 --name nexus --restart=always -v /etc/localtime:/etc/localtime:ro -v /nexus-data:/nexus-data  sonatype/nexus3:3.49.0

访问:http://127.0.0.1:8081/

默认管理员登录账号密码:admin/yourpasswd

初始访问会要求输入密码,账号是admin,密码在数据目录下:nexus-data/admin.password,输入密码后开始配置,然后会要求输入新的密码。接下来的匿名登录这步根据实际来,方便的情况下允许,需要更新安全则不允许即可。

配置Maven Nexus私服

创建角色

通过设置-->Roles-->Create Roles创建一个开发者角色,赋予的权限如图所示,如需要其他权限,修改角色权限即可。

默认的管理员和匿名登录角色保留即可。

创建用户

默认会有一个管理员用户和一个匿名登录用户,我们可以根据实际需要添加开发者用户,对应上面创建的开发者角色。

配置代理仓库

添加一个阿里的maven2 proxy,直接在repositories列表上点击创建repository,然后选择maven2 proxy。

创建成功后,再次进入修改此代理界面,发现URL显示是我们内网的地址了,也就是我们可以通过http://127.0.0.1:8081/repository/nexus-aliyun/ 这个内网的地址通过maven私服去下载镜像。

阿里maven私服代理地址:http://maven.aliyun.com/nexus/content/groups/public/

公共仓库添加代理仓库

参考下图,直接将创建好的代理仓库添加到maven-pulic即可。

setting.xml maven配置文件配置私服

配置文件参考如下,注意修改localRepository本地仓库地址。

<?xml version="1.0" encoding="UTF-8"?><settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd"><localRepository>C:\User\xxx\.m2\repository</localRepository><interactiveMode>true</interactiveMode><offline>false</offline><pluginGroups><pluginGroup>org.mortbay.jetty</pluginGroup><pluginGroup>org.jenkins-ci.tools</pluginGroup><pluginGroup>org.sonatype.plugins</pluginGroup>  </pluginGroups><servers><server><id>maven-releases</id><username>yourusername</username><password>yourpasswd</password></server><server> <id>maven-snapshots</id><username>yourusername</username><password>yourpasswd</password></server></servers><mirrors><mirror><id>maven-public</id><name>maven-public</name><mirrorOf>*</mirrorOf><url>http://127.0.0.1:8081/repository/maven-public/</url></mirror></mirrors><profiles><profile><id>nexus</id><activation><activeByDefault>false</activeByDefault><jdk>1.8</jdk></activation><repositories><repository><id>central</id><url>http://127.0.0.1:8081/nexus/content/groups/public/</url><releases><enabled>true</enabled></releases><snapshots><enabled>true</enabled></snapshots></repository></repositories>      <pluginRepositories><pluginRepository><id>central</id><url>http://127.0.0.1:8081/nexus/content/groups/public/</url><releases><enabled>true</enabled></releases><snapshots><enabled>true</enabled></snapshots></pluginRepository></pluginRepositories></profile></profiles><activeProfiles><activeProfile>nexus</activeProfile></activeProfiles></settings>

配置项目pom.xml

配置项目的pom.xml,打包时将jar包上传到私服

<plugins><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-compiler-plugin</artifactId><version>3.8.1</version><configuration><target>1.8</target><source>1.8</source><encoding>UTF-8</encoding><skip>true</skip></configuration></plugin><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-deploy-plugin</artifactId><version>2.7</version></plugin>
</plugins>

配置distributionManagement

    <distributionManagement><repository><id>maven-releases</id><url>http://127.0.0.1:8081/repository/maven-releases/</url></repository><snapshotRepository><id>maven-snapshots</id><url>http://127.0.0.1:8081/repository/maven-snapshots/</url></snapshotRepository></distributionManagement>

修改发布策略

默认情况下,对于release版本的项目是不允许重复发布的,为了方便,我们修改配置,允许重复发布。

发布项目版本到maven nexus私服

执行以下指令即可发布到私服

mvn deploy

登录到nexus查看,我们的发布的项目已在私服,这时其他开发人员可以直接从私服更新所需的jar,避免所有开发人员需要所有源码进行本地安装。

Maven Nexus3 私服搭建、配置、项目发布(docker方式)相关推荐

  1. maven私服、将项目发布到maven私服、从私服下载jar到本地仓库、将第三方jar安装到本地仓库和maven私服

    上面启动start时,jdk1.9报错,解决方法参考:https://blog.csdn.net/qq_33638719/article/details/83064664 访问http://local ...

  2. 【Centos7内网环境Nexus3私服搭建】

    1.使用背景 在项目开发的过程中,我们通常在内部网络进行开发,在内网环境开发中我们经常遇到 Maven包.Npm包.Yum镜像.Docker镜像等无法联网下载问题,当然这些问题也可以通过离线安装的方式 ...

  3. Maven 连接私服资源库配置

    2019独角兽企业重金招聘Python工程师标准>>> 1.介绍 我们项目中逐渐转入到maven构建体系下.项目在构建和部署时会依赖很多包,这些包默认从公共资源库下载,由于是国外地址 ...

  4. nexus3私服搭建

    应用场景 maven库分为本地仓库和远程仓库(包括私服和中央仓库).公司自己设立,只为公司内部共享使用,同时减少外部访问和下载频率等. 使用Nexus搭建私服 下载 官网链接:https://www. ...

  5. 【Maven】私服搭建与使用:nexus,repository,mirror,distributionManagement

    一.应用场景与相关介绍 私服public仓库理解:私服,即私人的服务器,可以看作就是一台电脑.这个电脑专门供我们连接然后下载和存放jar包,而我们给这个电脑分为了几个仓库,其中一个叫做public.不 ...

  6. Maven+Nexus私服搭建

    一.下载 直接通过官方下载最新的开源版,里面也有详细的安装教程. 官方下载地址:http://www.sonatype.org/nexus/go 二.安装 安装过程很简单,只需要把文件拷贝到某路径下即 ...

  7. maven工程私服仓库配置(阿里云仓库)

    1.首先在maven的配置文件中添加阿里云镜像 在setting.xml文件中添加 <mirrors>         <mirror>             <id& ...

  8. 1. maven环境本地搭建配置

    文章目录 1. maven下载 2. 下载完成后选择路径解压 3. 配置系统变量 4. 配置环境变量 5. CMD检测是否配置成功 6. 配置settings文件 7. 配置依赖下载后的保存位置 8. ...

  9. Docker容器搭建 Nexus3 私服

    Docker容器搭建 Nexus3 私服 1.介绍 2.搭建私服 2.1.下载nexus镜像 2.2.新建挂载目录 2.3.创建容器 2.4.访问nexus页 3.私服使用 3.1.私服配置 1.介绍 ...

最新文章

  1. kernel vim阅读 设置tags的标签
  2. IntelliJ IDEA 查看类继承关系图,太强大了!
  3. Component 初识组件
  4. android仿ios消息框,Android仿IOS提示框
  5. 如何阅读一本书?阅读的高效方法
  6. 微型计算机的最少配是,只有SD卡大小的微型电脑 配Atom处理器
  7. r语言中检测异常值_R中的异常值检测
  8. AI 人工智能包含的领域方向
  9. sulley对Modbus协议fuzz实验
  10. flowable-ui(v6.7.2)简单的请假流程审批操作(二)
  11. 面经—CV秋招40万+offer上岸经验:分享100道CV最新面试题
  12. web应用程序的访问与服务器,本地机的带宽关系 + 带宽详解
  13. ubuntu安装Linux集成服务,Hyper-v R2中安装ubuntu后,安装集成环境。--梦飞翔的地方(梦翔天空)...
  14. Virtualbox虚拟分配空间扩展(适用于动态分配磁盘)
  15. iOS经典面试题大全
  16. JointCalib-雷达与相机的外参标定
  17. comment on的意义
  18. 盘点低延时网络架构中使用的那些黑科技!
  19. MySQL中show的相关命令
  20. 构建高效的整车系统级别评估平台,百度安全自动驾驶风险安全研究亮相NDSS2022AutoSec...

热门文章

  1. LED节能灯制作方法 以及电路图
  2. 来自以色列的10种最热门的自动驾驶技术
  3. ZeroMemory、memset 和 “={0}” 三者用于清零操作的区别
  4. Lucene03---索引位置的优化(内存和磁盘配合使用)
  5. 邮件群发效果怎么样?外贸新手如何做好邮件营销?
  6. 周志华《机器学习》课后习题解答系列(三):Ch2 - 模型评估与选择
  7. 【DDR3 控制器设计】(2)DDR3 初始化测试
  8. kernel 中WiFi模块报错:device not accepting address .error -71
  9. 一个女生物联人的自学单片机笔记2021.1.21(单片机---单片机的最小系统)
  10. ubuntu网速慢的原因