1.安装maven仓库

1:下载安装包
    wget https://mirrors.cnnic.cn/apache/maven/maven-3/3.5.4/binaries/apache-maven-3.5.4-bin.tar.gz --no-check-certificate
2:解压
    tar -xf apache-maven-3.5.4-bin.tar.gz 
3:前往/usr/local/下创建文件夹 maven
    cd /usr/local/
    mkdir maven
    
4:将解压后的文件移至maven,并且更新名称 叫maven加版本号
    mv 解压后的文件路径 maven
    mv 文件名称 新名称

5:配置环境变量 vi /etc/profile
    export MAVEN_HOME=/usr/local/maven/maven3.5.4
    export PATH=$PATH:$MAVEN_HOME/bin
    
6:验证是否安装成功
    mvn -version

7:修改maven存放jar包的路径 前往安装目录下的conf目录下,vi setting.conf,找到 <localRepository>/path/to/local/repo</localRepository> 在注释后面添加
    <localRepository>/usr/local/maven/repository</localRepository>
    保存退出
    记得创建对应的repository文件夹

8:执行命令 下载jar包
    mvn help:evaluate -Dexpression=settings.localRepository | grep -v '\[INFO\]'
    

2.安装maven私有库 nexus官网

1.先前往/usr/local/installactionPackage下载安装包(需要fanqiang下载,建议本地下载后上传到linux服务器上)
    wget http://download.sonatype.com/nexus/3/nexus-3.19.1-01-unix.tar.gz

2.解压
    tar -xf nexus-3.19.1-01-unix.tar.gz
    记得删除安装包

3.将解压后的文件移至/usr/local/下面 (有两个文件 nexus-3.19.1-01 与 sonatype-work)
    #记得创建nexus文件夹
    mv 文件名称 ../nexus

4.编辑bin目录下的nexus 修改RUN_AS_USER参数(3.19.1-01这个版本已经不需要配置了)
    RUN_AS_USER=root
    保存退出
    
5.开放端口8081
    #开放端口
    /sbin/iptables -I INPUT -p tcp --dport 8081 -j ACCEPT
    #重启防火墙
    service iptables restart

6.配置nexus环境变量
    export PATH=$PATH:/usr/local/nexus/nexus-3.19.1-01/bin

7.启动
    nexus start
    
8.验证
    在浏览器打开http://localhsot:8081/

9.修改nexus的jvm内存 前往bin目录下 vi nexus.vmoptions,修改下面配置
    -Xms2048m
    -Xmx2048m
    -XX:MaxDirectMemorySize=2048m

10.修改端口,前往etc目录下,vim nexus.properties ,修改下面配置
    application-port=8081

11.修改数据存放的目录位置
    #在安装目录下面创建一个repository文件夹,将sonatype-work这个文件移至repository下面,最后配置一下 vi nexus-3.19.1-01/bin/nexus.vmoptions,修改如下
         -XX:LogFile=/usr/local/nexus/repository/sonatype-work/nexus3/log/jvm.log
        -Dkaraf.data=/usr/local/nexus/repository/sonatype-work/nexus3
        -Dkaraf.log=/usr/local/nexus/repository/sonatype-work/nexus3/log
        -Djava.io.tmpdir=/usr/local/nexus/repository/sonatype-work/nexus3/tmp

12.重新加载配置文件
    nexus force-reload
    
13.登录 用户名称是 admin
    #查看密码
        cat /data/nexusrepertory/sonatype-work/nexus3/admin.password
    

3.nexus基本命令和配置

0.基本命令
    nexus start|stop|run|run-redirect|status|restart|force-reload

1.启动
    nexus start

2.停止
    nexus stop

3.重启
    nexus restart

4.查看状态
    nexus status

5.修改配置后需要重新加载
    nexus force-reload

4.简介


Nexus有3个类型的数据仓库,分别是hosted,proxy,group。

hosted 宿主仓库:主要用于部署无法从公共仓库获取的构件以及自己或第三方的项目构件; 
proxy 代理仓库:代理公共的远程仓库; 
group 仓库组:Nexus 通过仓库组统一管理多个仓库,这样我们在项目中直接请求仓库组即可请求到仓库组管理的多个仓库。

Nexus预定义了2个本地仓库,分别是maven-releases, maven-snapshots。

maven-releases:这里存放我们自己项目中发布的构建, 通常是Release版本的。 
maven-snapshots:这个仓库非常的有用, 它的目的是让我们可以发布那些非release版本, 非稳定版本。

5.配置私服,从私服下载jar包

1.找到maven安装目录,编辑 vi setting.conf文件,新增如下
    <server>
    <!--这是server的id(注意不是用户登陆的id),该id与distributionManagement中repository元素的id相匹配。 -->
      <id>nexus</id>
      <username>admin</username>
      <password>123456</password>
     </server>
     
    <mirror>
        <!--该镜像的唯一标识符。id用来区分不同的mirror元素。  -->
        <id>nexus</id>
        <!--此处配置所有的构建均从私有仓库中下载 *代表所有,也可以写central -->
        <mirrorOf>*</mirrorOf>
        <name>internal nexus repository</name>
        <!--该镜像的URL。构建系统会优先考虑使用该URL,而非使用默认的服务器URL。  -->
        <url>http://localhost:8081/repository/maven-releases/</url>
    </mirror>

标签: usr, linux, repository, 仓库, maven, nexus, 私有, local

相关文章推荐

添加新评论,含*的栏目为必填