美文网首页javaWeb学习
Centos7 搭建私服Maven仓库

Centos7 搭建私服Maven仓库

作者: 你笑时很美丶 | 来源:发表于2019-04-25 20:33 被阅读23次

    部署环境:

    • CentOS 7
    • jdk1.8
    • nexus-3.16.1-02-unix.tar.gz

    下载地址:

    搭建步骤:

    • 安装jdk:https://www.jianshu.com/p/b3c0c160c8bf
    • 安装nexus:
      1.在/usr/local中新建nexus文件夹(mkdir -p nexus)
      2.使用xsftp将nexus-3.16.1-02-unix.tar.gz上传至nexus文件夹中:
    tar zxvf nexus-3.16.1-02-unix.tar.gz 
    

    3.解压后会多出两个文件夹,如图1:


    图1

    4.配置nexus的环境变量:

    vim /etc/profile
    #指定nexus路径
    export NEXUS_HOME=/usr/local/nexus/nexus-3.16.1-02
    #更新环境变量
    source /etc/profile
    

    5.设置nexus使用的jdk,我这里并没有指定

    vim ./bin/nexus
    #换成自己的jdk路径
    INSTALL4J_JAVA_HOME_OVERRIDE=/usr/local/java/jdk1.8.0_191
    
    
    图2

    6.运行 nexus-3.16.1-02 文件夹下 bin 目录的 nexus,启动Nexus服务:

    # 在/usr/local目录下时输入
    #此启动不输出日志,run命令会输出
    ./nexus-3.16.1-02/bin/nexus start
    #停止 命令
    ./nexus-3.16.1-02/bin/nexus stop
    

    7.会出现如图2所示:

    图3
    修改nexus.rc中的run_as_userroot
    vim ./bin/nexus.rc
    

    8.访问:http://localhost:8081默认账号/密码为:admin/admin123
    9.若为局域网,启动成功了却访问不了,可能是没有开启防火墙端口:

    #开启8081端口
    firewall-cmd --zone=public --add-port=8081/tcp --permanent
    #在不改变状态的条件下重新加载防火墙
    firewall-cmd --reload
    

    10.若想更改Nexus的数据以及相关日志存储位置,这里我没改

    #在nexus-3.16.1-02目录下
    vim ./bin/nexus.vmoptions
    #日志
    -XX:LogFile=./sonatype-work/nexus3/log/jvm.log
    #数据存放在路径
    -Dkaraf.data=./sonatype-work/nexus3
    -Djava.io.tmpdir=./sonatype-work/nexus3/tmp
    #更新内存分配和其他JVM参数
    -Xms1200M
    -Xmx1200M
    

    11.修改Nexus的默认端口,这里我没改

    #在nexus-3.16.1-02目录下
    vim ./etc/nexus-default.properties 
    #默认为8081
    application-port=8081
    
    图3

    访问http://localhost:8081/

    成功

    12.setting.xml中应用:

    <!--配置私服-->
    <servers>
            <server>
                <id>nexus-snapshots</id>
                <username>admin</username>
                <password>admin123</password>
            </server>
            <server>
                <id>nexus-releases</id>
                <username>admin</username>
                <password>admin123</password>
            </server>
    </servers>
    <profiles>
    <profile>
                <id>nexusRepository</id>
                <repositories>
                    <repository>
                        <id>nexus</id>
                        <name>nexus is Repository</name>
                        <url>http://192.168.1.96:8081/repository/maven-public/</url>
                        <!-- 默认就是true -->
                        <releases>
                            <enabled>true</enabled>
                        </releases>
                        <!-- 默认是是false,需手动打开 设置为true -->
                        <snapshots>
                            <enabled>true</enabled>
                        </snapshots>
                    </repository>
                </repositories>
            </profile>
    </profiles>
    <!-- 这里必须激活profile 才能生效 -->
        <activeProfiles>
            <activeProfile>nexusRepository</activeProfile>
        </activeProfiles>
    

    相关文章

      网友评论

        本文标题:Centos7 搭建私服Maven仓库

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