在内网中使用maven_使用nexus搭建内网maven镜像

背景:

内网环境,使用maven构建管理项目只能自己搭建镜像。nexus3.x需联网使用,所以选用nexus2.x来搭建镜像

环境:

3、windows10

步骤:

搭建nexus环境

1、将下载好的nexus-professional-2.14.10解压至任意目录。

2、打开刚才解压的目录,首先进入config目录,修改nexus.properties,修改默认端口号。

#修改端口号

application-port=12345

application-host=0.0.0.0

nexus-webapp=${bundleBasedir}/nexus

nexus-webapp-context-path=/nexus

# Nexus section

nexus-work=${bundleBasedir}/../sonatype-work/nexus

runtime=${bundleBasedir}/nexus/WEB-INF

# orientdb buffer size in megabytes

storage.diskCache.bufferSize=4096

打开cmd,进入nexus的bin目录,执行

nexus install

运行完成后,会生成windows服务,可以在windows服务列表里看到,默认是自动启动。

3、nexus启动后,会在sonatype-work/nexus/下面生成一批目录,其中storage/thirdparty目录就是存放各种依赖的目录。

4、将我们外网电脑在maven中下载好的repository复制到sonatype-work/nexus/storage/thirdparty中,重启nexus服务。本地maven仓库地址一般会在C:\Users\your user\.m2\repository

5、访问Repository Path 就是本地的镜像地址,后面会用到。

本地镜像仓库

配置maven

1、修改MAVEN_HOME/config/settings.xml,增加以下节点

localRep

central

the Mirror for neiwang

http://your ip:12345/nexus/content/groups/public/

2、更新IDE的maven配置,这里以eclipse为例。打开eclipse-window-Preferences-Maven-User Settings,选择Global Settings,选择maven安装目录下conf目录中的settings.xml,选择完毕后,点击Update Settings 。

eclipse配置maven

3、更新你的maven项目。

结束:

后续更新依赖的时候,只需把外网的repository复制到nexus的sonatype-work/nexus/storage/thirdparty中即可。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值