您的位置:首页 > 其它

Windows环境使用Nexus-3.x搭建Maven私服

2017-07-05 17:06 671 查看
本文主要讲解在Wiindows环境下搭建最新出的Nexus 3.x私服。

1、搭建私服的必要性

一般情况下,各个公司的开发团队为了提高开发效率,都会使用项目构建工具进行开发。常见的构建工具有Ant、Grandle和Maven等。而使用构建工具,一般情况下都需要管理各种依赖的插件,需要频繁连接服务器。而考虑到开发效率,就需要搭建私服。总体来说,使用私服具有以下的好处:节省外网带宽加速Maven构建,提高效率内部部署构件灵活的安全和权限管理其他优势

2、Nexus安装和启动

常见的搭建私服的软件有:Apache基金会的Archiva——开源JFrog的Artifatory——核心开源Sonatype的Nexus——核心开源,具有社区版本免费使用。最流行的Maven仓库管理软件。由于本文针对的是Maven私服,因此使用Nexus3.x的社区版。

2.1 环境准备

我的前期环境配置:(1)Windows7 x64系统(2)JDK1.8(3)Maven3最核心的是下载安装Nexus3.x,这里的具体版本是nexus-3.1.0-04。下载地址

2.2 安装

Nexus3.x是免安装的,下载之后解压到一个文件夹NEXUS_HOME中。至此,下载安装完成。

2.3 Nexus端口配置

Nexus3.x的配置和Nexus1.x、Nexus2.x的配置完全不同。Nexus1.x、Nexus2.x的端口配置方法参考:http://jingyan.baidu.com/article/4853e1e5739e661909f72695.html而Nexus3.x的安装目录架构如图:"nexus-3.1.0-04"为Nexus3.x的安装文件目录,“sonatype-work”为Nexus3.x的工作(或称之为数据)目录。和以往不同的是,若想修改Nexus自带的Jetty容器的服务端口,需要修改“NEXUS_HOME\sonatype-work\nexus3\etc”目录下的“nexus.properties”配置文件,修改其中的端口即可。默认端口为:8081,但是通常该端口可能已经被占用,从而出现JettyServerFailed to Start的错误,抛出地址已经被占用的异常,无法绑定,从而导致错误。例如我这里端口改为:8083

2.4 Nexus运行

虽然在“NEXUX_HOME\nexus\nexus-3.1.0-04\bin”目录下存在nexus.exe的可执行程序,但是双击程序或者右键使用管理员运行,都不能启动Nexus的服务。正确的打开姿势是:通过命令行运行。执行步骤如下:Win+R,输入cmd回车,打开命令提示符窗口。一路cd命令,进入“NEXUX_HOME\nexus\nexus-3.1.0-04\bin”目录。输入 nexus,exe /run,回车即可运行。对于不熟悉命令提示符命令操作的用户,还有一种简单的打开命令提示符窗口的办法:进入“NEXUX_HOME\nexus\nexus-3.1.0-04\bin”目录。按住Shift键,同时鼠标右键单击,选择“在此处打开命令窗口”。输入 nexus,exe /run,回车即可运行。输入启动nexus的指令:nexus.exe /run出现如下的信息,表示启动成功。

3 登录Nexus管理系统

Nexus的默认服务端口为8081,默认的用户名是:admin,密码:admin123。由于我修改了端口号为8083,打开浏览器,输入:localhost:8083即可进入Nexus管理系统。点击右上角的Sign in按钮,输入用户名和密码,进入仓库管理系统。

4 仓库配置

仓库配置详见官方文档:http://books.sonatype.com/nexus-book/reference3/admin.html#admin-repositories

<distributionManagement>
<snapshotRepository>
<id>nexus</id>
<name>nexus</name>
<url>http://localhost:8888/repository/maven-snapshots/</url>
</snapshotRepository>
<repository>
<id>nexus</id>
<name>nexus</name>
<url>http://localhost:8888/repository/maven-releases/</url>
</repository>
</distributionManagement>
 <profile>    <id>nexus</id>    <repositories>    <repository>    <id>nexus</id>    <name>Nexus</name>    <url>http://localhost:8888/repository/maven-public/</url>    <releases><enabled>true</enabled></releases>    <snapshots><enabled>true</enabled></snapshots>    </repository>    </repositories>    <pluginRepositories>    <pluginRepository>    <id>nexus</id>    <name>Nexus</name>    <url>http://localhost:8888/repository/maven-public/</url>    <releases><enabled>true</enabled></releases>    <snapshots><enabled>true</enabled> </snapshots>    </pluginRepository>    </pluginRepositories>    </profile>
<server>        <id>nexus</id>        <username>admin</username>        <password>admin123</password>    </server>    <server>        <id>releases</id>        <username>admin</username>        <password>admin123</password>    </server>    <server>      <id>snapshots</id>      <username>admin</username>      <password>admin123</password>    </server>
 <mirror>    <id>nexus</id>    <mirrorOf>*</mirrorOf>    <name>Nexus</name>    <url>http://localhost:8888/repository/maven-public/</url>  </mirror>  </mirrors>
https://www.sonatype.com/download-oss-sonatype?hsCtaTracking=10655413-f621-4c62-be46-df84cf6b6b90%7C79f798b3-f0df-4370-b569-0eda6e14390e

                                            
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: