一、安装配置Nexus

1、  下载nexus

https://www.sonatype.com/download-oss-sonatype

2、  解压:tar -zxfnexus-3.5.2-01-unix.tar.gz

3、  进入bin目录启动:./nexus run &

出现如下界面启动成功

-------------------------------------------------

Started Sonatype Nexus OSS 3.5.2-01

-------------------------------------------------

4、  访问http://10.211.55.7:8081/ 可以登录

默认端口号:8081

默认账号:admin

默认密码:admin123

5、  配置修改

5.1、修改运行nexus3所使用的用户:

[root@bigdata1 bin]#vi nexus.rc

run_as_user=”root”

5.2、修改nexus3启动所使用的jdk版本

[root@bigdata1 bin]#vi nexus

INSTALL4J_JAVA_HOME_OVERRIDE=/data/program/software/java8

5.3、修改nexus3默认端口

[root@bigdata1 etc]# vinexus-default.properties

application-port=8282

5.4、修改nexus3数据以及相关日志的存储位置

[root@bigdata1etc]# vi nexus.vmoptions

-XX:LogFile=./sonatype-work/nexus3/log/jvm.log

-Dkaraf.data=./sonatype-work/nexus3

-Djava.io.tmpdir=./sonatype-work/nexus3/tmp

二、修改settings.xml配置,使用nexus私有库

<?xml version="1.0"encoding="UTF-8"?>

<settingsxmlns="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.0http://maven.apache.org/xsd/settings-1.0.0.xsd">

<localRepository>${user.home}/.m2/repository</localRepository>

<interactiveMode>true</interactiveMode>

<offline>false</offline>

<pluginGroups>

<pluginGroup>org.mortbay.jetty</pluginGroup>

<pluginGroup>org.jenkins-ci.tools</pluginGroup>

</pluginGroups>

<servers>

<server>

<id>nexus-releases</id>

<username>admin</username>

<password>admin123</password>

</server>

<server>

<id>nexus-snapshots</id>

<username>admin</username>

<password>admin123</password>

</server>

</servers>

这是Server的ID(不是登录进来的user),与Maven想要连接上的repository/mirror中的id元素相匹配。username,password:这两个元素成对出现,表示连接这个server需要验证username和password。在nexus中,默认管理员用户名为admin,密码为admin123。这里使用两个服务器配置,分别对应release和snapshot。

<mirrors>

<mirror>

<id>nexus-releases</id>

<mirrorOf>*</mirrorOf>

<url>http://10.211.55.7:8081/repository/maven-public/</url>

</mirror>

<mirror>

<id>nexus-snapshots</id>

<mirrorOf>*</mirrorOf>

<url>http://10.211.55.7:8081/repository/maven-snapshots/</url>

</mirror>

</mirrors>

id,name:唯一的镜像标识和用户友好的镜像名称。id被用来区分mirror元素,并且当连接时候被用来获得相应的证书。

mirrorOf:镜像所包含的仓库的Id。例如,指向Maven central仓库的镜像(http://repo1.maven.org/maven2/),设置这个元素为central。更多的高级映射例如repo1,repo2 或者*,!inhouse都是可以的。没必要一定和mirror的id相匹配。在这里mirrorOf项当然应该使用*,以表明是所有仓库都会被镜像到指定的地址。

url:镜像基本的URL,构建系统将使用这个URL来连接仓库。这里应该添nexus仓库的地址,地址可以在nexus仓库页面中找到。

<profiles>

<profile>

<id>nexus</id>

<repositories>

<repository>

<id>nexus-releases</id>

<url>http://nexus-releases</url>

<releases><enabled>true</enabled></releases>

<snapshots><enabled>true</enabled></snapshots>

</repository>

<repository>

<id>nexus-snapshots</id>

<url>http://nexus-snapshots</url>

<releases><enabled>true</enabled></releases>

<snapshots><enabled>true</enabled></snapshots>

</repository>

</repositories>

<pluginRepositories>

<pluginRepository>

<id>nexus-releases</id>

<url>http://nexus-releases</url>

<releases><enabled>true</enabled></releases>

<snapshots><enabled>true</enabled></snapshots>

</pluginRepository>

<pluginRepository>

<id>nexus-snapshots</id>

<url>http://nexus-snapshots</url>

<releases><enabled>true</enabled></releases>

<snapshots><enabled>true</enabled></snapshots>

</pluginRepository>

</pluginRepositories>

</profile>

</profiles>

profile项代表maven的基本配置。按照maven的一贯尿性,很多xml的配置项都会有一个配置项的复数形式作为父节点,以保证该配置项可以配置多个。在profiles项中,当然也可以配置多个profile,不过在这里配一个就够了。下面介绍profile项的各个子节点。

id:用来确定该profile的唯一标识。

repositories/repository:用以规定依赖包仓库的相关信息。在下属节点中,id就不用多说了;URL是指仓库地址,这里使用伪造的地址,否则即使设置了mirror,maven也有可能会直接从中央仓库下载包;releases和snapshots放在一块说吧,这两个节点下属的enable节点用以规定对应的依赖包是否对当前策略有效,假如将snapshot的enable项设为disable,则不会下载snapshot包。

<activeProfiles>

<activeProfile>nexus</activeProfile>

</activeProfiles>

</settings>

用以规定当前启用的配置,将对应profile的ID加入到这一项即可使profile生效。

三、上传jar到nexus

第一种方式:

mvndeploy:deploy-file -DgroupId=com.alibaba -DartifactId=dubbo -Dversion=2.8.4-Dpackaging=jar -Dfile=/Users/zhangyong/Documents/software/dubbo-2.8.4.jar-Durl=http://10.211.55.7:8081/repository/maven-releases/-DrepositoryId=nexus-releases

DrepositoryId和settings.xml里配置的id一样

第二种方式:

代码的pom.xml中直接接入

<distributionManagement>

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

</repository>

</distributionManagement>

mvn deploy

架构实战项目心得(四):使用Nexus配置Maven私有仓库的更多相关文章

  1. 使用Nexus配置Maven私有仓库

    使用Nexus配置Maven私有仓库 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.安装配置Nexus 1>.下载nexus 下载地址:https://www.sonat ...

  2. [maven] 使用Nexus创建maven私有仓库

    1.为什么需要maven私有仓库? 从Maven中央仓库下载所需的jar包,需要外网的支持.如果公司不能上外网的话则不能从中央仓库下载所需jar包,公司网速慢的时候也会影响项目构建的速度.用户可以用n ...

  3. 架构实战项目心得(四)(补):Maven settings.xml的所有标签详解

    文章内容较长,各位看客可以根据自己需要CTRL+F 直接定位到自己需要了解的地方哦~ <?xmlversion="1.0" encoding="UTF-8" ...

  4. 架构实战项目心得(八):dubbo知识的整理

    1 Dubbo启动时检查.集群容错.负载均衡.线程模型的设置以及选项:    启动时检查:(1)Dubbo默认会在启动的时候检查依赖的服务是否可用,不可用时会抛出异常.阻止Spring初始化完成.以便 ...

  5. maven+nexus配置本地私有仓库

    以下是settting.xml的配置 <?xml version="1.0" encoding="UTF-8"?> <settings> ...

  6. 使用nexus创建maven私有仓库

    nexus安装 nexus下载 wget https://sonatype-download.global.ssl.fastly.net/nexus/oss/nexus-2.11.1-01-bundl ...

  7. 架构实战项目心得(十四):spring-boot结合Swagger2构建RESTful API测试体系

    一.添加依赖: <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-s ...

  8. 架构实战项目心得(三):JAVA和MAVEN的环境配置

    1 java环境配置: 1 下载并安装jdk1.82 配置java环境变量: vi /etc/profile,在文件底部增加以下内容:export JAVA_HOME=/data/program/so ...

  9. 架构实战项目心得(七):使用SpringBoot+Dubbo+Mybatisplus+Oracle搭建后台项目框架(二)

    接下来我们将整合mybatisplus+Oracle,实现一个简单的查询.(期间踩了很多坑,遇到一些问题,还好慢慢解决了.现在是通过配置文件的方式来进行dubbo服务的注册和发布,希望以后能在学习和实 ...

随机推荐

  1. Swagger简单实例

    随着技术的不断发展,网站框架也开始向:前后端分离的形态发展,而且前端技术和后端技术在各自的道路上越走越远.而web api 接口成了前后端唯一的联系.所以web api会变得越来越重要. 那么什么是W ...

  2. jQuery为DOM动态追加事件

    处理一个列表绑定,因为是一个展示项目,没有使用复杂的插件,直接jsrender写了个模板,但是后面有一个操作按钮,去查看数据详情,想到了jquery使用on进行事件委托,然后就开搞 最初是这样写的: ...

  3. HAOI2010 工厂选址

    题目链接:戳我 数组开小火葬场qwqwq 就是一个贪心吧.对于一个数,我们知道只有两种摆放方式.所以我们可以先都放到新的里面,然后做一下新的-原先的差,按照差从大到小排序,依次提取数值减去即可. 代码 ...

  4. [BJ2006] 狼抓兔子

    题目链接:戳我 按理说以dinic\(O(M*N^2)\)的时间复杂度应该是过不去的(呃我也知道这个上界很松).但是最小割确实可以水过去?? 但是本着写正解的精神,我还是学了学平面图和对偶图,跑最短路 ...

  5. ERWin7.2在Windows 8.1中生成数据库遇到的问题!

    我在Windows 8.1中使用ERWin7.2,想象以前在windows 7 或者XP里那样先预览一下要生成的SQL语句,结果我发现居然没有“preview”按钮了,自然也就无法看到要生成的SQL语 ...

  6. OCP2018最新题库,052新题库及答案整理-25题

    25.Which is true about logical and physical database structures? (Choose the best answer) A. An undo ...

  7. 从零开始完整搭建 Spring-Boot 项目开发框架的教程

    前言 难度:简单 类型:step-by-step 适用:初学者,完全没有接触过 Spring-Boot 开发环境:jdk 1.8 关键词:java, sring-boot, spring-mvc, r ...

  8. CoreImage 图片处理

    CoreImage 是苹果 iOS5新增的一个 OC 框架,提供了强大的图像处理功能, 用于对基于像素的图像进行操作与分析, 提供了很多滤镜(Filter),形成强大的自定义效果 CIImage 类 ...

  9. PowerBuilder中新建PBL

    首先需要打开工作区间workspace , 然后选择你的第一个根pbl文件. 如图所示: 选择WorkSpace下的第一个application.PBT文件,然后单击鼠标右键,选择属性Properti ...

  10. PHP 五大运行模式

    查看当前php 运行模式 php_sapi_name(); 运行模式 关于PHP目前比较常见的五大运行模式: 1)CGI(通用网关接口/ Common Gateway Interface) 2)Fas ...