使用Nexus构建私有服务器

本文介绍如何在Linux环境下使用Maven+Nexus构建私有仓库。从下载Nexus、安装配置到导入本地仓库文件,详细说明每一步操作流程。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

开发中,若不能连接互联网,且使用到了Maven开发,那是很郁闷的。但是先将开发中要用的jar缓存到本地仓库,在借助本地仓库拷贝,进行开发。若涉及到团队开发,还是希望共用一个Maven库,这时候可以借助Nexus构建私有服务器。

1.下载Nexus:地址Download Archived Nexus Releases,可以选择喜欢的版本,下载完毕后,由于我是在Linux,我选择了Download Nexus 2.12.0-01(TGZ)

2.解压Nexus到指定文件夹

sudo mkdir /nexus
sudo tar -zxvf nexus-2.12.0-01-bundle.tar.gz  -C   /nexus

Nexus不推荐使用root启动服务,所以将文件夹所有者改为普通用户

sudo chown user1:user1 nexus -R

3.启动Nexus服务

cd /nexus/nexus-2.12.0-01/bin
./nexus start
4.登陆http://192.168.186.137:8081/nexus访问登陆名admin/admin123(初始账号)



点击Repositories->Central->Configuration中的Download Remote Indexes设置为true,并保存。

5.修改Maven配置文件,在Maven插件的settting.xml配置文件中 <setting>中添加如下代码

	<profiles>
        <profile>
            <id>dev</id>
            <repositories>
                <repository>
                    <id>local-linux-nexus</id>
                    <url>http://192.168.186.137:8081/nexus/content/groups/public/</url>
                    <releases>
                        <enabled>true</enabled>
                    </releases>
                    <snapshots>
                        <enabled>true</enabled>
                    </snapshots>
                </repository>
            </repositories>
        </profile>
    </profiles>

    <!-- activeProfiles | List of profiles that are active for all builds. | -->
    <activeProfiles>
        <activeProfile>dev</activeProfile>
    </activeProfiles>


这里基本上就完成了。但是若是在完全不能连接互联网环境下,可以将本地仓库导入到仓库服务器上,

然后将所有的文件移动到中央仓库。

在拷贝本地仓库之前


现在整个本地仓库考本到Linux服务器上,如拷贝到桌面上


移动所有的相关文件

cd /home/docker/Desktop/m2/repository
mv * /nexus/sonatype-work/nexus/storage/public/
查看此时导入情况


先关参考

Maven实战(Maven+Nexus建立私服【Linux系统】)

Maven学习 (四) 使用Nexus搭建Maven私服

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值