美文网首页Ubuntu高手进阶
Ubuntu Nexus3 Maven私服

Ubuntu Nexus3 Maven私服

作者: Lrxc | 来源:发表于2019-07-17 14:58 被阅读0次

一 安装nexus

1 下载nexus镜像
官网:https://help.sonatype.com/repomanager3/download

  1. 上传至ubuntu
//解压到自己的目录
tar -zxvf  nexus-3.17.0-01-unix.tar.gz .
  1. 启动nexus
    Nexus默认的端口是8081,可以在etc/nexus-default.properties配置中修改。
//进入bin目录下
./nexux start

4.等待一分钟 浏览器访问
http://192.168.234.132:8081/


image.png

可以看到账号admin 密码需要手动获取

//获取密码
$ cat /usr/local/sonatype-work/nexus3/admin.password

二 上传代码至Nexus

  1. 设置厂库可以重复上传
    左侧选择Reposiroty—选择厂库maven-releases—找到Hosted—选择Allow redeploy— Save


    image.png

    2 在maven的 settings.xml 中配置

     <servers>
        <server>
          <!--nexus 仓库名-->
          <id>maven-releases</id>
          <!--nexus 仓库的账号密码-->
          <username>admin</username>
          <password>123</password>
        </server>
     </servers>

3 配置项目pom.xml文件

    <!--配置maven私服地址,用户打包上传-->
    <distributionManagement>
        <repository>
            <!--id 对应新建仓库的名字-->
            <id>maven-releases</id>
            <url>http://192.168.234.132:8081/repository/test-repository/</url>
        </repository>
    </distributionManagement>

4 发布到nexus


image.png

出现BUILD SUCCESS 代表成功。
5 查看nexus厂库


image.png

三 使用私服

  1. 直接在项目的pom.xml 添加
    <dependencies>
        <!--maven依赖:上传到nexus的代码信息-->
        <dependency>
            <groupId>com.bxlt</groupId>
            <artifactId>nexus_api</artifactId>
            <version>1.0-RELEASE</version>
        </dependency>
    </dependencies>

    <repositories>
        <!--配置nexus私服地址-->
        <repository>
            <id>maven-releases</id>
            <name>maven-releases</name>
            <url>http://192.168.234.132:8081/repository/test-repository/</url>
        </repository>
    </repositories>
  1. 查看下载地址


    image.png

四. maven的 settings.xml 综合配置

<?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>E:\Repository\repository</localRepository>

    <!--远程仓库名、用户名、密码,有些仓库访问是需要安全认证的 -->
    <servers>
        <server>
            <!-- 远程厂库的id(Name) -->
            <id>maven-public</id>
            <username>admin</username>
            <password>admin</password>
        </server>
    </servers>
    
    <!--为仓库列表配置的下载镜像列表。  -->
    <mirrors>
        <mirror>
            <!--远程厂库的id(Name)  -->
            <id>maven-public</id>
            <!--此处配置所有的构建均从私有仓库中下载 *代表所有,也可以写central -->
            <mirrorOf>*</mirrorOf>
            <url>http://192.168.234.130:8091/repository/maven-public/</url>
        </mirror>
    </mirrors>
    
    <!--根据环境参数来调整构建配置的列表。-->
    <profiles>
        <profile>
            <id>nexus</id>
            <!--远程仓库列表。  -->
            <repositories>
                <repository>
                    <!-- 远程厂库的id(Name) -->
                    <id>maven-public</id>
                    <url>http://192.168.234.130:8091/repository/maven-public/</url>
                    <!--true或者false表示该仓库是否为下载某种类型构件(发布版,快照版)开启。 -->
                    <releases><enabled>true</enabled></releases>
                    <snapshots><enabled>true</enabled></snapshots>
                </repository>
            </repositories>
            <!-- 插件仓库列表 -->
            <pluginRepositories>
                <pluginRepository>
                    <id>maven-public</id>
                    <url>http://192.168.234.130:8091/repository/maven-public/</url>
                    <releases><enabled>true</enabled></releases>
                    <snapshots><enabled>true</enabled></snapshots>
                </pluginRepository>
            </pluginRepositories>
        </profile>
    </profiles>
    
    <!--激活配置-->
    <activeProfiles>
        <!--profile下的id-->
        <activeProfile>nexus</activeProfile>
    </activeProfiles>
</settings>

参考文章:

https://blog.csdn.net/fly910905/article/details/78668677
https://cloud.tencent.com/developer/article/1014577

相关文章

  • 8 私服相关

    1 私服:nexus搭建流程Maven Nexus3私服搭建指南https://www.jianshu.com/p...

  • Ubuntu Nexus3 Maven私服

    一 安装nexus 1 下载nexus镜像官网:https://help.sonatype.com/repoma...

  • Nexus3 私服的使用

    一、下载与安装 Maven Nexus3私服搭建指南,点击查看 二、Maven配置 打开Maven配置文件 set...

  • maven学习笔记

    1.maven环境配置2.配置maven3.maven私服 nexus3 配置4.maven使用nexus仓库5....

  • Android 打包上传Maven私库

    一.Maven私服搭建 下载nexus3地址:https://www.sonatype.com/download-...

  • Android 打包上传Maven库

    一.Maven私服搭建 下载nexus3地址:https://www.sonatype.com/download-...

  • Ubuntu server下搭建Maven私服Nexus

    Ubuntu server下搭建Maven私服Nexus Maven私服Nexus的作用,主要是为了节省资源,在内...

  • 基于Docker搭建Maven私服

    初次搭建Maven私服,记录一下自己遇到的两个小问题。 1.碰到了400错误:因为自己Maven nexus3中新...

  • CentOS7 搭建 nexus

    nexus是一种maven私服软件,很方便项目构建和管理。 本人使用的是nexus3的镜像的tar包,版本3.13...

  • Maven私服搭建

    什么是maven私服? 工程中如何使用? 如何接入maven私服? 了解maven私服 分为本地和远程 远程包括:...

网友评论

    本文标题:Ubuntu Nexus3 Maven私服

    本文链接:https://www.haomeiwen.com/subject/covqlctx.html