Nexus安装指南

一、Windows 环境下的安装与配置
1.1、安装前提
JDK:1.7 及以上版本,并配置相关环境变量。

1.2、Nexus 安装
首先,我们需要从官网上下载 Nexus 安装包。
Nexus2.14 下载地址:https://www.sonatype.com/download-oss-sonatype
下载 nexus-2.14.8-01-bundle.zip 后解压至某一目录,路径
中最好不要带中文名称及空格,解压后目录清单如下:

image.png

解压后,进入安装目录下 nexus-2.14.8-01\bin\目录:
image.png

使用管理员权限打开 cmd,在当前文件夹下执行以下命令安装服务:nexus install
image.png

1.3、Nexus 启动配置
有两种启动方式:
1.使用管理员权限打开 cmd 在当前文件夹下执行以下命令:nexus start


image.png

2.右键电脑-->管理-->服务-->nexus-->启动。(可设置为手动启动。)

Nexus的默认地址为:http://localhost:8081/nexus/,访问后显示如
下内容,则说明启动成功:

image.png

二、Linux 环境下的安装与配置
2.1、安装前提
JDK:1.7 及以上版本,并配置相关环境变量。
2.2、Nexus 安装
首先,我们需要从官网上下载 Nexus 安装包。
Nexus2.14 下载地址:https://www.sonatype.com/download-oss-sonatype
下载 nexus-2.14.1-01-bundle.tar.gz 并解压即可:

#cd /home/tools
#tar zxvf nexus-2.4.0-09-bundle.tar.gz
#mv nexus-2.4.0-09 /usr/local/nexus

2.3、Nexus 启动配置
使用命令启动:

#cd /usr/local/nexus/bin
#./nexus start
#./nexus stop

默认地址为:http://localhost:8081/nexus/,访问后显示如
下内容,则说明启动成功:

image.png

三、普元EOS仓库部署
3.1、部署前提
用户已经安装了 Nexus2.14,并获得了普元离线编译包storage-eosplatform76.zip。
3.2、登录
点击右上角 Log in,默认账户密码为:admin/admin123。


image.png

点击左侧 Repositories,即可看见系统自带的一些仓库:


image.png
Nexus 的仓库分为 4 类:
1.hosted 宿主仓库:本质上就是本地仓库。
2.proxy 代理仓库:代理远程仓库,配置远程仓库地址后,可以从远程仓库获取 jar 包。
3.virtual 虚拟仓库:用于适配 Maven 1 格式,基本不用。
4.group 仓库组:通过仓库组的概念统一管理多个仓库,在项目中请求仓库组即可请求组中的所有仓库。

3.3、新建仓库
由上仓库分类,我们可以新建一个 hosted 仓库以供使用。
点击 Add,选择 hosted 仓库:


image.png

填入 ID 和 name,然后点击 Save进行保存:


image.png

3.4、添加离线 jar 包
进入安装目录下\sonatype-work\nexus\storage\,这里保存的是 Nexus 所有仓库的信息和 jar 包,进入我们新建的仓库 primeton_maven:


image.png

然后将 storage-eosplatform76.zip 解 压 到 安 装 目 录 下\sonatype-work\nexus\storage\ primeton_maven\文件夹下:


image.png

在浏览器中,选择新建的仓库,点击 Browse Storage,并点击刷新,可以看到所需 jar 包已经导入:
image.png

3.5、配置 maven setting 文件
打开 maven 安装目录,在 conf 文件夹下 setting.xml 文件,进行如下配置:
示例一:

<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
http://maven.apache.org/xsd/settings-1.0.0.xsd">
<localRepository>E:\test</localRepository>
<profiles>
<profile>
<id>myNexus</id>
<repositories>
<repository>
<id>test</id>
<url>http://localhost:8081/nexus/content/repositories/test/
</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>test</id>
<url>http://localhost:8081/nexus/content/repositories/test/
</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
<activeProfiles>
<activeProfile>myNexus</activeProfile>
</activeProfiles> 
</settings>

示例二

<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
                      http://maven.apache.org/xsd/settings-1.0.0.xsd">
    <localRepository>E:\Maven_Repository</localRepository>
    <profiles>
        <profile>
            <id>primeton-repositorys</id>
            <repositories>
                <repository>
                    <id>primeton_maven</id>
                    <url>http://localhost:8081/nexus/content/repositories/primeton_maven/</url>
                    <releases>
                        <enabled>true</enabled>
                    </releases>
                    <snapshots>
                        <enabled>false</enabled>
                    </snapshots>
                </repository>
                <repository>
                    <id>primeton-public-repository</id>
                    <url>http://localhost:8081/nexus/content/groups/primeton_public_repositories/</url>
                    <releases>
                        <enabled>true</enabled>
                    </releases>
                    <snapshots>
                        <enabled>false</enabled>
                    </snapshots>
                </repository>
                <repository>
                    <id>primeton-p2-repository</id>
                    <url>http://localhost:8081/nexus/content/repositories/primeton_p2_eclipse_repository/.meta/p2</url>
                    <layout>p2</layout>
                    <releases>
                        <enabled>true</enabled>
                    </releases>
                    <snapshots>
                        <enabled>false</enabled>
                    </snapshots>
                </repository>
                <repository>
                    <id>primeton-release-p2-repository</id>
                    <url>http://localhost:8081/nexus/content/repositories/primeton_products_release/.meta/p2</url>
                    <layout>p2</layout>
                    <releases>
                        <enabled>true</enabled>
                    </releases>
                    <snapshots>
                        <enabled>false</enabled>
                    </snapshots>
                </repository>
            </repositories>
            <pluginRepositories>
                <pluginRepository>
                    <id>primeton_maven</id>
                    <url>http://localhost:8081/nexus/content/repositories/primeton_maven/</url>
                    <releases>
                        <enabled>true</enabled>
                    </releases>
                    <snapshots>
                        <enabled>false</enabled>
                    </snapshots>
                </pluginRepository>
            </pluginRepositories>
        </profile>
    </profiles>
    <activeProfiles>
        <activeProfile>primeton-repositorys</activeProfile>
    </activeProfiles>    
    
</settings>

注意:
1.localRepository 为本地 maven 存储库地址。
2.profile 下 ID 与 activeProfiles 中对应。
3.repository 和 pluginRepository 中,ID 与我们新建的仓库 ID对应,url 与 Nexus 生成的仓库地址对应。

配置完成后 maven 在获取 jar 包时,就会从新建仓库中获取。

©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 193,968评论 5 459
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 81,682评论 2 371
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 141,254评论 0 319
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 52,074评论 1 263
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 60,964评论 4 355
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 46,055评论 1 272
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 36,484评论 3 381
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 35,170评论 0 253
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 39,433评论 1 290
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 34,512评论 2 308
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 36,296评论 1 325
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 32,184评论 3 312
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 37,545评论 3 298
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 28,880评论 0 17
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 30,150评论 1 250
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 41,437评论 2 341
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 40,630评论 2 335

推荐阅读更多精彩内容