服务器之家:专注于服务器技术及软件下载分享
分类导航

云服务器|WEB服务器|FTP服务器|邮件服务器|虚拟主机|服务器安全|DNS服务器|服务器知识|Nginx|IIS|Tomcat|

服务器之家 - 服务器技术 - 服务器知识 - Nexus私服的搭建原理及教程解析

Nexus私服的搭建原理及教程解析

2020-09-09 21:07咔咔kk 服务器知识

这篇文章主要介绍了Nexus私服的搭建原理及教程解析,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下

一.为什么要构建Nexus私服

公司所有开发成员没有外网,通过局域网连接 nexus 私服,由私服连接外网。

把项目发布到私服.其他人员从私服下载。

二.使用私服之后架构图

Nexus私服的搭建原理及教程解析

三.搭建 Nexus

3.1 nexus-2.10-1bundle.zip 解压到任意非中文目录中

3.2进入 nexus-2.10-1\bin\jsw\indows-x86-4(对应自己系统)

Nexus私服的搭建原理及教程解析

以windows64系统为例

Nexus私服的搭建原理及教程解析

instal-nexus.bat 安装服务
star-nexus.bat 开启服务
stop-nexus.bat 停止服务
unistal-nexus.bat 卸载服务

3.3 登录后台

在浏览器输入 htp:/localhost:8081/nexus

默认端口8081
默认用户名admin
默认密码admin123

若需调整可配置nexus-2.10-1\conf\exus.proerties

Nexus私服的搭建原理及教程解析

四.使用 maven 连接私服

4.1修改maven 的 setings.xml

 

<?xml version="1.0" encoding="UTF-8"?>

	<settings>

	<localRepository>G:\tool\m2\myrepository</localRepository>

	<mirrors>

 

 

<mirror>

	<id>nexus-releases</id>

	<mirrorOf>*</mirrorOf>

	<url>http://localhost:8081/nexus/content/groups/public</url>

	</mirror>

	<mirror>

	<id>nexus-snapshots</id>

	<mirrorOf>*</mirrorOf>

	<url>http://localhost:8081/nexus/content/repositories/apache-snapshots/

	</url>

	</mirror>

	</mirrors>

 

 

<profiles>

	<profile>

	<id>jdk-1.7</id>

	<activation>

	<activeByDefault>true</activeByDefault>

	<jdk>1.7</jdk>

	</activation>

	<properties>

	<maven.compiler.source>1.7</maven.compiler.source>

	<maven.compiler.target>1.7</maven.compiler.target>

	<maven.compiler.compilerVersion>1.7</maven.compiler.compilerVersion>

	</properties>

	</profile>

 

 

<profile>

	<id>nexusTest</id>

	<repositories>

	<repository>

	<id>local-nexus</id>

	<url>http://127.0.0.1:8081/nexus/content/groups/public/</url>

	<releases>

	<enabled>true</enabled>

	</releases>

	<snapshots>

	<enabled>true</enabled>

	</snapshots>

	</repository>

	</repositories>

	</profile>

 

 

</profiles>

 

 

<activeProfiles> <!--激活 id为 nexusTest的 profile -->

	<activeProfile>nexusTest</activeProfile>

	</activeProfiles>

	<servers>

	<server>

	<id>releases</id>

	<username>admin</username>

	<password>admin123</password>

	</server>

	<server>

	<id>snapshots</id>

	<username>admin</username>

	<password>admin123</password>

	</server>

	</servers>

	</settings>

 

G:\tool\m2\myrepository 存放本地仓库位置

http://127.0.0.1:8081 Nexus服务器ip及端口

admin/ admin123 Nexus服务器登录用户名和密码

五.把项目发布到私服的步骤

5.1 pom.xml 中配置私服路径

 

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

	<modelVersion>4.0.0</modelVersion>

	<groupId>com.bjsxt</groupId>

	<artifactId>test</artifactId>

	<version>0.0.1-SNAPSHOT</version>

 

 

<distributionManagement>

	<repository>

	<id>releases</id>

	<url>http://localhost:8081/nexus/content/repositories/releases</url>

	</repository>

	<snapshotRepository>

	<id>snapshots</id>

	<url>http://localhost:8081/nexus/content/repositories/snapshots</url>

	</snapshotRepository>

	</distributionManagement>

 

 

</project>

 

5.2 在 setings.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>

 

5.3 右键项目-> run as 输入 deploy

添加到项目后,后台可查询到对应包

Nexus私服的搭建原理及教程解析

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持服务器之家。

原文链接:https://www.cnblogs.com/hzcjd/p/12347172.html

延伸 · 阅读

精彩推荐