相关文章
一、为什么需要私服
有些公司并不提供外网给程序员,因此不能使用maven访问远程的仓库地址,所以很有必要在局域网里找一台有外网权限的机器;搭建nexus私服,然后程序员连到这台私服上,这样的话就可以通过这台搭建了nexus私服的电脑访问maven的远程仓库。
二、配置步骤
第一步:下载nexus-2.6.4-02.war包,然后拷贝到tomcat下的webapps目录中
http://www.sonatype.org/nexus/go Download the Nexus WAR distribution
第二步:启动tomcat
第三步:访问http://localhost:8088/nexus-2.6.4-02显示如下:
第四步:点击右上角“log in” ,输入username:admin 和Password:admin123登录
第五步:登录成功
第六步:点击Views/Repositories 中Repositories
Nexus内置仓库说明:
(1)Maven Central:该仓库代理Maven中央仓库,其策略为Release,因此只会下载和缓存中央仓库中的发布版本构件。
(2)Releases:这是一种策略为Release的宿主类型仓库,用来部署组织内部的发布版本构件。
(3)Snapshots:这是一个策略为Snapshot的宿主类型仓库,用来部署组织内部的快照版本构件。
(4)3rd party:这是一个策略为Release的宿主类型仓库,用来部署无法从公共仓库获得的第三方发布版本构件。
(5)Public Repositories:该仓库组将上述所有策略为Release的仓库聚合并通过一致的地址提供服务。
第七步:创建宿主目录和代理仓库
Hosted:本地仓库,通常我们会部署自己的构件到这一类型的仓库。 包括3rd party仓库,Releases仓库,Snapshots仓库
Proxy:代理仓库,它们被用来代理远程的公共仓库,如maven中央仓库。
Group:仓库组,用来合并多个hosted/proxy仓库,通常我们配置maven依赖仓库组。
第八步:创建仓库组
点击Public Repositories仓库,在Configurations栏中选取需要合并的仓库,点击箭头加到左边保存即可
第九步:下载Index索引并进行构建搜索(GAV搜索)
点击Views/Repositories菜单下面的Repositories,将这三个仓库 Apache Snapshots,Codehaus Snapshots,Central的Download Remote Indexes修改为 true。然后在这三个仓库上分别右键,选择Repari index,这样Nexus就会去下载远程的索引文件。
第十步:配置所有构建均从私服下载,在~/.m2/setting.xml中配置如下:
<settings>
<mirrors>
<mirror>
<!--此处配置所有的构建均从私有仓库中下载 *代表所有,也可以写central -->
<id>nexus</id>
<mirrorOf>*</mirrorOf>
<url>http://localhost:8088/nexus-2.6.4-02/content/groups/public</url>
</mirror>
</mirrors>
<profiles>
<profile>
<id>nexus</id>
<repositories>
<repository>
<id>nexus</id>
<name>local private nexus</name>
<url>http://localhost:8088/nexus-2.6.4-02/content/groups/public</url>
</repository>
</repositories>
</profile>
<profile>
<id>nexus-snapshots</id>
<repositories>
<repository>
<id>nexus-snapshots</id>
<name>local private nexus snapshots</name>
<url>http://localhost:8088/nexus-2.6.4-02/content/groups/public-snapshots</url>
</repository>
</repositories>
</profile>
</profiles>
<activeProfiles>
<!--make the profile active all the time -->
<activeProfile>nexus</activeProfile>
</activeProfiles>
第十一步:Nexus的访问权限控制,在~/m2/setting.xml中配置如下:
<!-- 设置发布时的用户名 -->
<servers>
<server>
<id> releases </id>
<username>admin</username>
<password>admin123</password>
</server>
<server>
<id> snapshots </id>
<username>admin</username>
<password>admin123</password>
</server>
</servers>
第十二步:
部署构建到Nexus,包含Release和Snapshot, 在项目根目录中pom.xml中配置:
<distributionManagement>
<repository>
<id>releases</id>
<name>Internal Releases</name>
<url>http://localhost:8088/nexus-2.6.4-02/content/repositories/releases/</url>
</repository>
<snapshotRepository>
<id>snapshots</id>
<name>Internal Snapshots</name>
<url>http://localhost:8088/nexus-2.6.4-02/content/repositories/snapshots/</url>
</snapshotRepository>
</distributionManagement>
第十三步:pom.xml
<distributionManagement>
<repository>
<id>releases</id>
<name>Internal Releases</name>
<url>http://localhost:8088/nexus-2.6.4-02/content/repositories/releases/</url>
</repository>
<snapshotRepository>
<id>snapshots</id>
<name>Internal Snapshots</name>
<url>http://localhost:8088/nexus-2.6.4-02/content/repositories/snapshots/</url>
</snapshotRepository>
</distributionManagement>
你还在等什么,赶快试试吧。
关注作者
相关推荐
配置Maven私服时,需要修改Maven的默认配置文件,此文件已经配置好Maven私服模板,只需要修改IP和对应的端口号即可
搭建Maven私服,并配置Nexus环境.rar
史上最全的maven setting配置,包括私服nexus,maven.aliyun.com,repo.maven.apache.org
nexus2.14.14.zip搭建maven私有仓库工具,linux版。在linux下解压,./bin/nexus start启动,默认情况下,不建议以root用户运行Nexus,可以修改bin/nexus中的配置跳过警告(修改RUN_AS_USER=root),vi bin/nexus,...
Maven Nexus 私服搭建 从零开始,资源下载、安装指导、开发配置说明
Maven配置文件Maven配置文件
Maven 安装与配置(csdn)————程序
详细介绍了nexus私服的配置及安装方法
Windows 下Nexus搭建Maven私服 Windows 下Nexus搭建Maven私服
maven的安装与配置; maven的安装与配置 ;maven的安装与配置
maven系列笔记(安装、下载jar、搭建私服)
apache-maven-3.5.0只配置了中央仓库,只要修改里面的本地仓库地址就可以使用了。 apache-maven-3.5.0-nexus配置了maven私服,有需要的,可以按照格式改成你自己的。
建立Maven私服 – Nexus下载、安装、配置、使用 建立Maven私服 – Nexus下载、安装、配置、使用
maven可用,已经配置了阿里云私服,改下仓库地址就可以了,很好用,亲测可用,速度快,点赞
依赖配置中资源的上传下载maven配置,私服配置说明
maven阿里云配置文件,采用maven3.5.2,是一个非常实用的配置文件。
Maven的安装、配置及使用入门
maven配置文件配置国内阿里云镜像
JDK和maven的环境变量配置,有图有真相