【From】 https://blog.csdn.net/qq250782929/article/details/51605965

Nexus Manager OSS 3.0 —Maven Repository

前言

网上基本搜不到 Nexus 3.0 版本以上的相关配置文档,最近刚好在弄,就顺便写下来了,当作笔记。
nexus官方文档

1.下载

下载地址:
http://www.sonatype.com/download-oss-sonatype

选择对应的版本下载,本文章以nexus-3.0.0-03-win64.zip版本为例。(其他版本大同小异)

Nexus 3.xx 版本除了Maven以外还支持 Docker ,NuGet ,npm ,Bower 。有时间的可以尝试一下。

2.解压

将下载好的zip格式的解压到指定目录。(Windows用户需注意目录路径不能含有中文,空格等字符

3.执行

3.0版本:进入到nexus的bin目录 nexus /start 执行

cd D:\nexus-3.0.0-03\bin
D:\nexus-3.0.0-03\bin>nexus /start

3.2版本:进入到nexus的bin目录 nexus /start 执行

cd D:\nexus-3.0.0-03\bin
D:\nexus-3.0.0-03\bin>nexus.exe /run

默认应用地址是http://localhost:8081,若需要更改:
3.0版本:

打开 ..\nexus-3.0.0-03\etc\org.sonatype.nexus.cfg

修改端口: application-port

修改ip: application-host 

3.2版本:

打开 ..\nexus\sonatype-work\nexus3\etc\nexus.properties

修改端口: application-port

修改ip: application-host 

4.配置 Nexus

用浏览器打开 http://localhost:8081

点击右上角Sign in 按钮登录。默认用户名:admin,密码:admin123

点击齿轮状配置按钮,进入配置页面:

进入Repository-Repositories

Repository的type属性有:proxy,hosted,group三种。

proxy:即你可以设置代理,设置了代理之后,在你的nexus中找不到的依赖就会去配置的代理的地址中找

hosted:你可以上传你自己的项目到这里面

group:它可以包含前面两个,是一个聚合体。一般用来给客户一个访问nexus的统一地址。

简单的说,就是你可以上传私有的项目到hosted,以及配置proxy以获取第三方的依赖(比如可以配置中央仓库的地址)。前面两个都弄好了之后,在通过group聚合给客户提供统一的访问地址

至于format,因为本文讲的的 Maven Repository ,所以请选择maven2;

系统默认就有以上几个Repository。点击maven-public 确保已经将 maven-central,maven-releases以及maven-snapshots都包含在里面。

maven-releases : 默认配置只能上传 release版本的项目

maven-snapshots: 默认配置只能上传 snapshots版本的项目

如有特殊要求,可以自己创建一个Version policy 为Mixed的Repository。

以上配置就能满足一般需求了。

5.使用 mvn deploy 向 Nexus服务器 上传项目

maven setting.xml配置:

<?xml version="1.0" encoding="UTF-8"?>
<settings>
<localRepository>E:/repository</localRepository>
<mirrors>
<mirror>
<!--This sends everything else to /public -->
<id>nexus</id>
<mirrorOf>*</mirrorOf>
<url>http://localhost:8081/repository/maven-public/</url>
</mirror>
</mirrors>
<servers>
<server>
<id>nexus</id>
<username>admin</username>
<password>admin123</password>
</server>
</servers>
</settings>

localRepository:本地库的地址

mirror:nexus地址

servers:nexus服务器登录名和密码

1.使用cmd上传

mvn deploy:deploy-file -DgroupId=com.cxx -DartifactId=fu -Dversion=1.0.0 -Dpackaging=jar -Dfile=D:\gworkspace\work\cxx\fu\target\fu.jar -Durl=http://localhost:8081/repository/maven-releases/ -DrepositoryId=nexus -s D:\maven-3.2.1\conf\settings.xml

参数说明:

-D 传入指定参数 分别对应pom中的 groupId,artifactId,version,packaging
file 本地jar的路径
url Repository Url (请选择对应release,snapshots或mixed的url)
repositoryId 对应setting.xml中server id
-s setting.xml的路径(如果使用默认conf中的setting,则无需配置)

2.使用IDE上传

项目中的pom文件添加

<distributionManagement>
<repository>
<id>nexus</id>
<name>maven-releases</name>
<url>http://localhost:8081/repository/maven-releases/</url>
</repository>
</distributionManagement>

id:对应setting.xml中server id
name:nexus Repository name
url:nexus Repository url

然后使用IDE自带的Maven deploy就可以了。

然后就可以在nexus中看到你上传的:

这样你的maven项目就能引用你所上传的项目了。

[转] Nexus OSS 3.xx 体验的更多相关文章

  1. docker nexus oss

    docker login/search x.x.x.x:8081 sonatype/docker-nexus Docker images for Sonatype Nexus with the Ora ...

  2. 试用 Nexus OSS 3.0 的docker仓库 (二)

    试用 Nexus OSS 3.0 的docker仓库 (一) : http://www.cnblogs.com/wzy5223/p/5410990.html 三. 创建docker私有仓库,docke ...

  3. 试用 Nexus OSS 3.0 的docker仓库 (一)

    Nexus 3.0 可以创建三种docker仓库: 1. docker (proxy)      代理和缓存远程仓库 ,只能pull 2. docker (hosted)    托管仓库 ,私有仓库, ...

  4. 【Maven学习】Nexus OSS私服仓库的备份与迁移

    背景 在上一篇博客 [Maven学习]Nexus OSS私服仓库的安装和配置 中,我们已经在机房搭建好了新的Nexus OSS私服仓库.下面是两个版本的Nexus OSS私服仓库的对比图. 老的Nex ...

  5. 【Maven学习】Nexus OSS私服仓库的安装和配置

    背景 公司的代码依赖是通过Maven进行管理的,而Maven的私库我们使用的是Nexus,目前使用的版本是Nexus Repository Manager OSS 2.12.1. 但是由于之前我们搭建 ...

  6. Maven与Nexus OSS

    Maven 是一个项目管理和构建自动化工具,是Apache Fundation下的一个Java项目.常用于Java项目中依赖管理 下载直接去官网 安装Maven 已经编译的二进制包 直接解压到安装目录 ...

  7. kubernetes实战篇之nexus oss服务器部署及基于nexus的docker镜像仓库搭建

    系列目录 Nexus oss仓库管理平台搭建 Nexus是一款仓库管理工具,支持Npm,bower,maven,nuget,apt,yum甚至docker,helm等各种仓库,说的通俗以下,就是私服镜 ...

  8. Nexus OSS私服仓库的备份与迁移

    背景 在上一篇博客 [Maven学习]Nexus OSS私服仓库的安装和配置 中,我们已经在机房搭建好了新的Nexus OSS私服仓库.下面是两个版本的Nexus OSS私服仓库的对比图. 老的Nex ...

  9. Nexus OSS 3 搭建并配置使用 Docker & Git LFS 仓库

    转载自:https://cloud.tencent.com/developer/article/1010590 1.Nexus OSS 3 介绍 我们知道 Nexus 是一个强大的 Maven 仓库管 ...

随机推荐

  1. ORA-00054、ORA-08002

    https://docs.oracle.com/cd/B10501_01/server.920/a96525/e7500.htm ORA-00054 resource busy and acquire ...

  2. Hello_Motion_Tracking 任务一:Project Tango采集运动追踪数据

    我们来看一下中的几个基本的例子 (区域描述.深度感知.运动追踪.视频4个) 参考:Google Tango初学者教程 1. hello_motion_tracking package com.proj ...

  3. ZOJ3703 Happy Programming Contest 2017-04-06 23:33 61人阅读 评论(0) 收藏

    Happy Programming Contest Time Limit: 2 Seconds      Memory Limit: 65536 KB In Zhejiang University P ...

  4. java并发编程实战:第十三章----显示锁

    一.Lock与ReentrantLock Lock接口中定义了一种无条件.可轮询的.定时的以及可中断的锁获取操作,所有加锁和解锁的方法都是显式的. 1 public interfece Lock 2 ...

  5. AndroidStudio-永远无法进入

    由于出现了莫名其妙的,AndroidStudio已过时错误信息 就去删除了: C:\Users\Administrator\.android C:\Users\Administrator\.Andro ...

  6. WCF快速上手(二)

    服务端是CS程序,客户端(调用者)是BS程序 一.代码结构: 二.服务接口Contract和实体类Domain INoticeService: using Domain; using System; ...

  7. 学习迭代器实现C#异步编程——仿async/await(一)

    .NET 4.5的async/await真是个神奇的东西,巧妙异常以致我不禁对其实现充满好奇,但一直难以窥探其门径.不意间读了此篇强文<Asynchronous Programming in C ...

  8. 【cocos2d-x 手游研发小技巧(3)Android界面分辨率适配方案】

    先感叹一下吧~~android的各种分辨率各种适配虐我千百遍,每次新项目我依旧待它如初恋···· 每家公司都有自己项目工程适配的方案,这种东西就是没有最好,只有最适合!!! 这次新项目专项针对andr ...

  9. java学习笔记—标准连接池的实现(27)

    javax.sql.DataSource. Java.sql.* DataSource 接口由驱动程序供应商实现.共有三种类型的实现: 基本实现 - 生成标准的 Connection 对象 – 一个D ...

  10. 【12c OCP】最新CUUG OCP-071考试题库(49题)

    49.(11-1) choose the best answer Examine the structure of the SHIPMENTS table: You want to generate ...