Maven私有仓库的搭建

Maven私有仓库的搭建

1. Nexus的安装

官网下载nexus,然后通过rz命令上传该压缩文件

如果提示rz命令不支持,yum安装 yum install rzsa

tar zxvf nexus-2.12.0-01-bundle.tar.gz  解压缩

mv nexus-2.12.0-01 nexus            重命名文件

rm nexus-2.12.0-01-bundle.tar.gz       删除压缩文件  

进入nexus文件下的bin目录

cd /root/nexus/bin

启动nexus

./nexus start

提示如下错误

 

大概意思就是要在环境配置export RUN_AS_USER=root,临时配置

输入以下命令:export RUN_AS_USER=root

然后执行./nexus start就不会再提示了

也可以在系统里面永久配置

vi /etc/profile  

加入export RUN_AS_USER=root

source /etc/profile

然后再重新启动

 

2. 同步中央仓库

访问http://192.168.0.40:8081/nexus/

如遇无法访问,执行下列命令即可

firewall-cmd --zone=public --add-port=8081/tcp --permanent

systemctl restart firewalld.service

启动后如下页面

 

 

点击右上角login 输入密码 默认admin/admin123

 

将所有typeproxyconfiguration配置选项中DownloadRemoteIndex置为True,然后点击Save保存

 

新建组

 

将右边的Available Repositories全部拖到左边点击Save保存

 

Releases仓库的Deployment Policy设置为Allow ReDeploy

 

在Linux上进入该/root/sonatype-work/nexus/indexer/central-ctx目录上传文件

cd /root/sonatype-work/nexus/indexer/central-ctx 这个目录下原有的文件可以删除掉

 

上传完成后,三个文件要在同一个目录下,执行下面的命令

java -jar indexer-cli-5.1.1.jar -u nexus-maven-repository-index.gz -d ./

 

 

此时在外部访问就会实现索引的查找了

 

3. maven私有库的配置

maven编译时如果想直接从私服获取所需jar包,需要在mavensettings.xml文件中作如下配置

找到maven的安装路径,打开settings.xml文件

将以下配置添加到文件中

    <profile>  

       <id>center</id>  

      <repositories>    

        <repository>    

            <id>nexus</id>  

            <name>nexus</name>    

            <url>http://192.168.0.140:8081/nexus/content/groups/public</url>    

            <releases>    

                <enabled>true</enabled>    

            </releases>    

            <snapshots>    

                <enabled>true</enabled>    

            </snapshots>    

        </repository>

        

        <!-- 第三方仓库 -->

        <repository>    

            <id>nexus_thirdparty</id>  

            <name>nexus_thirdparty</name>    

            <url>http://192.168.0.140:8081/nexus/content/repositories/thirdparty</url>    

            <releases>    

                <enabled>true</enabled>    

            </releases>    

            <snapshots>    

                <enabled>true</enabled>    

            </snapshots>    

        </repository>

           

      </repositories>   

  

  

      <pluginRepositories>    

        <pluginRepository>    

            <id>nexus</id>    

            <name>nexus</name>    

            <url>http://192.168.0.140:8081/nexus/content/groups/public</url>    

            <releases>    

                <enabled>true</enabled>    

            </releases>    

            <snapshots>    

                <enabled>true</enabled>    

            </snapshots>    

        </pluginRepository>

        

        <pluginRepository>    

            <id>nexus_thirdparty</id>    

            <name>nexus_thirdparty</name>    

            <url>http://192.168.0.140:8081/nexus/content/repositories/thirdparty</url>    

            <releases>    

                <enabled>true</enabled>    

            </releases>    

            <snapshots>    

                <enabled>true</enabled>    

            </snapshots>    

        </pluginRepository>    

    </pluginRepositories>   

    </profile>

  </profiles>

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值