nexus搭建maven

上传人:第*** 文档编号:38765240 上传时间:2018-05-07 格式:DOC 页数:13 大小:868KB
返回 下载 相关 举报
nexus搭建maven_第1页
第1页 / 共13页
nexus搭建maven_第2页
第2页 / 共13页
nexus搭建maven_第3页
第3页 / 共13页
nexus搭建maven_第4页
第4页 / 共13页
nexus搭建maven_第5页
第5页 / 共13页
点击查看更多>>
资源描述

《nexus搭建maven》由会员分享,可在线阅读,更多相关《nexus搭建maven(13页珍藏版)》请在金锄头文库上搜索。

1、Nexus 搭建 Maven 本地仓库服务器 Windows 平台下使用(Maven 私服)1、 下载下载 Nexus 开源版:http:/nexus.sonatype.org/downloads/ 选择需要的版本下载 这里选择下载:nexus-oss-webapp-1.9.2.4-bundle.zip 。解压改压缩包到任意目录(这里选择路径:D:nexus) ,得到两个文件夹: D:nexunexus-oss-webapp-1.9.2.4 和 D:nexussonatype-work。nexus-oss-webapp-1.9.2.4 包含 nexus 的运行环境和应用程序,sonatype-

2、work 包含了个人配置和存储构建的地方。在 D:nexusnexus-oss-webapp-1.9.2.4conf plexus.properties 文件中,可以修改 nexus 监听端口以及工作区的路径。Nexus 默认监听端口是 8081。2、 安装安装 Nexus 服务服务。进入目录 D:nexusnexus-oss-webapp-1.9.2.4binjsw,会看到有很多 个版本,在 windows 平台下,选择 windows-x86-32(32 位机子使用)或者 windows- x86-64(64 位机子使用) ,这里选择 windows-x86-64。进入目录 D:nexus

3、nexus-oss-webapp-1.9.2.4binjswwindows-x86-64,会看到批处理文 件 Installnexus.bat,双击运行这个文件,将 nexus 安装成为 windows 服务,安装成功 之后,在运行框输入 services.msc 打开“服务”窗口,可以看到多了 nexus 服务。3、 开启开启 nexus 服务服务。依然在目录 D:nexusnexus-oss-webapp-1.9.2.4binjswwindows-x86- 64 目录,有问价 Startnexus.bat ,双击运行此文件既可以开启 Nexus 服务。也可以再 “服务”窗口右键开启服务。文

4、件 Stopnexus.bat 是关闭 nexus 服务,文件 Uninstallnexus.bat 是卸载 nexus 服务。文件 Pausenexus.bat 暂停 nexus 服务,文件 Resumenexus.bat 唤醒 nexus 服务(前提是 nexus 被暂停了) 。4、 访问访问 nexus 服务服务。Nexus 默认监听端口是 8081,打开浏览器,输入 http:/localhost:8081/nexus,可以看到 nexus 服务管理,但是需要登录才能进行管理。 在右上角点击 Log In,默认账号 admin,默认密码 admin123。5、 配置配置 nexus 服

5、务服务。登录之后,在左边栏可以看到几个分栏,在 view/Repositories 一栏,点击 Repositories ,进入仓库设置。在右边栏找到 Apache SnapShots ,选中它,在下方出现的选项框中切换到 configuration,找到 Remote Repository Accces 下面的 Download Remote Indexes,设置 值为 true,然后保存“save” 。同样,还有两个仓库 Maven Central、CodeHaus Snaphots,也要把 Download Remote Indexes 值设置为 true,并保存。保存之后,在右边的仓库

6、列表中分别右键选中刚才三个仓库,选中 repair Index,更新 并下载远程索引。到此,nexus 服务就配置完了。6、 Maven 使用使用 Nexus 服务服务。启动 eclipse,窗口首选项MavenInstallations,可以添 加自己下载的 maven,也可以继续使用 eclipse 安装 maven 插件的时候内置的 maven。 这里选择添加自己下载的 maven。点击“add” ,相应路径下面的 maven 根目录。这里 是 D:nexusapache-maven-3.0.3。添加之后,默认选中添加的 maven,然后自动搜索到 maven 全局配置文件, setti

7、ngs.xml。 想要 maven 使用刚刚配置的 nexus 服务作为仓库服务器,需要修改 settings.xml 文件。A、修改、修改 *可以不修改,但是默认是存放在用户目录下面的,也就是可以不修改,但是默认是存放在用户目录下面的,也就是 C 盘,如果盘,如果 C 盘不大,盘不大, 可以将此路径修改到别的盘。可以将此路径修改到别的盘。找到 maven 的 conf 目录下的 settings.xml 文件,打开文件,找到行:/path/to/local/repo将注释去掉,然后将“/path/to/local/repo”修改成本地磁盘的的某个路径,这个是存放 eclipse 项目需要引用

8、的 jar 包的(在 eclipse 项目添加 maven 依赖的时候,eclipse 自动从 nexus 服务器中下载 jar 包,然后存放到这个路径,默认路径是“/.m2/repository” ,也就 是用户目录下面 C:Usersljj.m repository, ) 。这里选择 D:nexus.m2repository,变成:D:/nexus/.m2/repositoryB、修改、修改 在 mirriors 节点下面添加:nexus-publicpublichttp:/127.0.0.1:8081/nexus/content/groups/public将镜像执行本地 nexus 服务

9、。C、修改、修改 在节点 profiles 下面添加:nexusnexuslocal private nexushttp:/127.0.0.1:8081/nexus/content/groups/publictruetruenexuslocal private nexushttp:/127.0.0.1:8081/nexus/content/groups/publictruetrue将仓库应用指向本地 nexus 服务地址。这个是下载远程 jar 包的时候,将 jar 存放到本 地 nexus 服务地址,eclipse 项目添加 maven 引用的时候,eclipse 从本地 nexus 服务地

10、 址下载 jar 包。D、最后,修改节点、最后,修改节点nexus激活 id 是 nexus 的配置。所有配置完,文件如下:D:/nexus/.m2/repositorynexus-publicpublichttp:/127.0.0.1:8081/nexus/content/groups/publicnexusnexuslocal private nexushttp:/127.0.0.1:8081/nexus/content/groups/publictruetruenexuslocal private nexushttp:/127.0.0.1:8081/nexus/content/group

11、s/publictruetruenexus将此文件复制到用户目录下的.m2 文件夹中,这样做的原因是:使用 eclipse 新建的项 目默认使用 maven 插件内置的版本,而内置版本默认的本地 jar 包仓库存放在用户目录 下的.m2,也就是默认引用这个目录下面的 settings.xml。两个地方都存放这个配置好的 settings.xml 就不会引起 maven 不能使用 nexus 服务的情况。 ()配置好之后,选择 mavenUser Settings ,选择 settings.xml 文件,可以使用默认路径 下面的 settings.xml 文件(因为已经被替换成了配置好的 xml

12、 文件),也可以选择 D:nexusapache-maven-3.0.3conf 路径下面的 settings.xml 文件。这里选择默认。选择 之后点击“Update Settings” ,eclipse 自动搜索配置路径,并在 Local Repository 的路径 下面存放从本地 nexus 服务器上面下载过来的 jar 包(那么默认的用户目录下面的 repository 文件夹可以删掉了,只需要留下 settings.xml 文件) 。Local Repository 的路径 下面的 jar 包也就是 eclipse 项目需要用到的 jar 包,如果不小心删掉了,不要紧,在 ecli

13、pse 项目中选择选中项目,右键mavenupdate dependencies 就会从本地 nexus 服 务器上下载过来。7、 Ecipse 项目使用项目使用 nexus 服务服务。打开 Eclipse,创建 maven projec,双击 pom.xml 文件进入 源代码编辑,在“project” 节点下面添加本地仓库服务器指向。nexus local private nexushttp:/l27.0.0.1:8081/nexus/content/groups/publictruefalsenexus-snapshots local private nexus http:/l27.0.0.1:8081/nexus/content/groups/public- snapshotsfalsetruenexus local private nexushttp:/l27.0.0.1:8081/nexus/content/groups/publictruefalsenexus-snapshots local private nexus http:/l27.0.0.1:8081/nexus/content/groups/public- snapshotsfalsetrue这样 eclipse 项目就是使用个人搭建的 nexus 本地仓库服务器,代替了使用远程仓库服 务器。

展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 学术论文 > 毕业论文

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号