Nexus搭建Maven私有仓库

2017/02/08

此次搭建是在Windows平台上操作的,搭建之前需要先安装JDK。

前言

Nexus Repository Manager is a Java application that requires a Java Runtime Environment. When you run Nexus Repository Manager, you are running a server application with a web-based user interface. The application itself runs with the Eclipse Jetty servlet container and Apache Karaf OSGi-container.

此次搭建是在Windows平台上操作的,搭建之前需要先安装JDK。

1.下载

最新版是nexus-3.2.0-01-win64.zip,可以从官网下载

2.注册服务

运行以下命令,注册为服务。 nexus.exe /install Nexus Service

这里写图片描述

配置成功。

这里写图片描述

3.启动服务

这里写图片描述

这里写图片描述

4.访问

这里写图片描述

5.登录

用户名:admin; 密码:admin123

这里写图片描述

这里写图片描述

没有Maven相关的jar包。

这里写图片描述

6.使用

使用maven-public仓库

maven配置

这里写图片描述

C:\Users\Administrator\.m2\settings.xml中添加以下配置

		<mirror>
			<!--This sends everything else to /public -->
			<id>nexus</id>
			<mirrorOf>central</mirrorOf>
			<url>http://localhost:8081/repository/maven-public/</url>
		</mirror>

package

在工程目录下,运行命令:mvn clean package

这里写图片描述

开始从私服下载jar包,快了很多。

私服中增加的jar包。

这里写图片描述

deploy

用IntelliJ IDEA,远程部署jar到私服。

1. settings.xml配置用户名和密码

一定要是C:\Users\用户名\.m2\settings.xml下面的settings.xml,IDEA在deploy的时候会在这个路径下面查找远程私服的用户名和密码。

		<server>  
			<id>snapshots</id>  
			<username>admin</username>  
			<password>admin123</password>  
		</server>

2. pom.xml文件配置

    <distributionManagement>
        <snapshotRepository>
            <id>snapshots</id>
            <url>http://localhost:8081/repository/maven-snapshots/</url>
        </snapshotRepository>
    </distributionManagement>

3. deploy

运行命令mvn clean -Dmaven.test.skip=true deploy

这里写图片描述

4. 成功

这里写图片描述

这里写图片描述

依赖使用

项目使用上传到私服的jar,运行命令mvn clean package

这里写图片描述

更多命令可以参考官方文档


作者:Wuxinshui
出处:http://wuxinshui.github.io
版权归作者所有,转载请注明出处

Post Directory