• centos7搭建maven私服nexus


    1.nexus

    Nexus Repository Manager(通常简称 Nexus 或 Nexus RM)是由Sonatype公司开发的一款开源的、强大的软件仓库管理工具,主要用于企业级的二进制组件(如Java库、Node.js模块、Python包等)存储、管理和分发。
    官方文档:https://help.sonatype.com/index.html?lang=en

    2.安装

    下载地址:https://help.sonatype.com/en/download.html
    如果不能下载的话可以用百度网盘下载;
    链接:https://pan.baidu.com/s/1zK3qnO47gfgn9MFxbrUrBA
    提取码:6fiq
    参考连接:https://blog.csdn.net/u012581020/article/details/130812447

    笔者官方没有下载成功,源码打包ui报错也没有成功

    将下载的包上传到服务器,执行命令:

    #将nexus 解压到/usr/local/ 目录
    tar -zxvf nexus-3.54.1-01-unix.tar.gz -C /usr/local/
    #创建nexus用户
    useradd nexus
    #更改/usr/local/目录的所有者未nexus
    chown -R nexus:nexus /usr/local/nexus-3.54.1-01
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6

    jdk安装

    #搜索jdk
    yum search openjdk
    #安装需要的jdk版本
    yum install java-1.8.0-openjdk.x86_64
    #安装成功查看jdk版本
    java -version
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6

    3.运行

    查看系统要求:https://help.sonatype.com/en/sonatype-nexus-repository-system-requirements.html#instance-resource-sizing-profiles

    #切换用户 nexus
    su - nexus
    #进入到安装目录
    cd /usr/local/nexus-3.54.1-01
    #后台启动 nexus相关命令:{start|stop|run|run-redirect|status|restart|force-reload}
    ./bin/nexus start 
    # 运行,关闭窗口程序停止运行,调试的时候使用
    ./bin/nexus run
    #停止
    ./bin/nexus stop
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10

    nexus 配置文件 etc/nexus-default.properties

    application-port=8081
    application-host=0.0.0.0
    nexus-args=${jetty.etc}/jetty.xml,${jetty.etc}/jetty-http.xml,${jetty.etc}/jetty-requestlog.xml
    nexus-context-path=/
    
    # Nexus section
    nexus-edition=nexus-pro-edition
    nexus-features=\
     nexus-pro-feature
    
    nexus.hazelcast.discovery.isEnabled=true
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12

    nexus jvm配置文件: bin/nexus.vmoptions

    
    -Xms2703m
    -Xmx2703m
    -XX:MaxDirectMemorySize=2703m
    -XX:+UnlockDiagnosticVMOptions
    -XX:+LogVMOutput
    -XX:LogFile=../sonatype-work/nexus3/log/jvm.log
    -XX:-OmitStackTraceInFastThrow
    -Djava.net.preferIPv4Stack=true
    -Dkaraf.home=.
    -Dkaraf.base=.
    -Dkaraf.etc=etc/karaf
    -Djava.util.logging.config.file=etc/karaf/java.util.logging.properties
    -Dkaraf.data=../sonatype-work/nexus3
    -Dkaraf.log=../sonatype-work/nexus3/log
    -Djava.io.tmpdir=../sonatype-work/nexus3/tmp
    -Dkaraf.startLocalConsole=false
    -Djdk.tls.ephemeralDHKeySize=2048
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19

    4.nexus 配置

    nexus 启动以后,访问web管理页面 http://ip:8081
    点击右上角登录,弹出登录框,显示admin默认密码路径:/usr/local/sonatype-work/nexus3/admin.password

    登录成功,根据向导设置
    修改密码以后,设置匿名访问:
    在这里插入图片描述
    启用匿名访问意味着默认情况下,用户可以在没有凭据的情况下从存储库搜索、浏览和下载组件。请考虑对您的组织的安全影响。

    禁用匿名访问应该谨慎选择,因为它需要所有用户和/或构建工具的凭据。

    允许仓库部署和更新:
    在这里插入图片描述
    在这里插入图片描述

    5.maven上传jar到nexus

    本地settings.xml配置:

    
    <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>${user.home}/.m3/repositorylocalRepository>
        <pluginGroups>
            
        pluginGroups>
    
        
        <proxies>
        proxies>
    
        <servers>
            
            <server>
                <id>nexus-releasesid>
                <username>adminusername>
                <password>admin123password>
            server>
            
            <server>
                <id>nexus-snapshotsid>
                <username>adminusername>
                <password>admin123password>
            server>
        servers>
        
        <mirrors>
            <mirror>
                <id>nexusid>
                <mirrorOf>*mirrorOf>
                <name>nexusname>
                <url>http://10.10.1.185:8081/repository/maven-public/url>
            mirror>
        mirrors>
    
        <profiles>
            <profile>
                <id>nexusid>
                
                
                <repositories>
                    <repository>
                        <id>centralid>
                        
                        <url>http://centralurl>
                        <releases><enabled>trueenabled>releases>
                        <snapshots><enabled>trueenabled>snapshots>
                    repository>
                repositories>
                <pluginRepositories>
                    <pluginRepository>
                        <id>centralid>
                        
                        <url>http://centralurl>
                        <releases><enabled>trueenabled>releases>
                        <snapshots><enabled>trueenabled>snapshots>
                    pluginRepository>
                pluginRepositories>
            profile>
        profiles>
    
        
        <activeProfiles>
            <activeProfile>nexusactiveProfile>
        activeProfiles>
    
    
    settings>
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
    • 58
    • 59
    • 60
    • 61
    • 62
    • 63
    • 64
    • 65
    • 66
    • 67
    • 68
    • 69
    • 70
    • 71
    • 72
    • 73
    • 74
    • 75
    • 76
    • 77
    • 78
    • 79
    • 80
    • 81
    • 82
    • 83
    • 84
    • 85
    • 86
    • 87

    idea maven配置:
    File->Settings->Maven->
    在这里插入图片描述

    创建maven项目,pom.xml新增部署仓库配置:

    
        <distributionManagement>
            <repository>
                <id>nexus-releasesid>
                <name>Nexus Release Repositoryname>
                <url>http://10.10.1.185:8081/repository/maven-releases/url>
            repository>
            <snapshotRepository>
                <id>nexus-snapshotsid>
                <name>Nexus Snapshot Repositoryname>
                <url>http://10.10.1.185:8081/repository/maven-snapshots/url>
            snapshotRepository>
        distributionManagement>
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13

    注意:id的内容需要和settings.xml配置中的server id一致

    上传jar包到nexus:
    方式一:选中项目-》右键->run Maven->deploy
    在这里插入图片描述

    方式二:maven命令

    mvn clean deploy
    
    • 1

    上传成功:
    在这里插入图片描述
    注意:如果版本号是以 SNAPSHOT结尾的如"1.0-SNAPSHOT",部署成功,jar被部署到maven-snapshots仓库。以其他则部署到maven-releases仓库。
    在这里插入图片描述
    新建maven项目,添加最近上传的依赖:

     <dependency>
                <groupId>cn.nexus.demogroupId>
                <artifactId>nexus-demo-biz2artifactId>
                <version>3.0.0version>
            dependency>
    
    • 1
    • 2
    • 3
    • 4
    • 5

    执行打包命令:

    mvn clean package
    
    • 1

    打包成功输出:
    在这里插入图片描述

  • 相关阅读:
    Linux之分区【详细总结】
    Java面试必问之面向对象“多态”
    PyCharm中环境变量与系统不相通问题
    MIMO-UNet复现,DeepRFT复现及总结
    【无标题】
    11 【Teleport CSS功能】
    2022年陕西省工程师职称申报,基本的职称论文要求您得知道啊
    深入浅出WMS之入库流程解析
    博客个人网页,是html博客网页设计
    Python 数据操作教程之如何在 Python 中转置矩阵
  • 原文地址:https://blog.csdn.net/tan809417133/article/details/138077119