Nexus安裝指南

一、Windows 環(huán)境下的安裝與配置
1.1、安裝前提
JDK:1.7 及以上版本,并配置相關(guān)環(huán)境變量。

1.2、Nexus 安裝
首先,我們需要從官網(wǎng)上下載 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

使用管理員權(quán)限打開 cmd,在當前文件夾下執(zhí)行以下命令安裝服務(wù):nexus install
image.png

1.3、Nexus 啟動配置
有兩種啟動方式:
1.使用管理員權(quán)限打開 cmd 在當前文件夾下執(zhí)行以下命令:nexus start


image.png

2.右鍵電腦-->管理-->服務(wù)-->nexus-->啟動。(可設(shè)置為手動啟動。)

Nexus的默認地址為:http://localhost:8081/nexus/,訪問后顯示如
下內(nèi)容,則說明啟動成功:

image.png

二、Linux 環(huán)境下的安裝與配置
2.1、安裝前提
JDK:1.7 及以上版本,并配置相關(guān)環(huán)境變量。
2.2、Nexus 安裝
首先,我們需要從官網(wǎng)上下載 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/,訪問后顯示如
下內(nèi)容,則說明啟動成功:

image.png

三、普元EOS倉庫部署
3.1、部署前提
用戶已經(jīng)安裝了 Nexus2.14,并獲得了普元離線編譯包storage-eosplatform76.zip。
3.2、登錄
點擊右上角 Log in,默認賬戶密碼為:admin/admin123。


image.png

點擊左側(cè) Repositories,即可看見系統(tǒng)自帶的一些倉庫:


image.png
Nexus 的倉庫分為 4 類:
1.hosted 宿主倉庫:本質(zhì)上就是本地倉庫。
2.proxy 代理倉庫:代理遠程倉庫,配置遠程倉庫地址后,可以從遠程倉庫獲取 jar 包。
3.virtual 虛擬倉庫:用于適配 Maven 1 格式,基本不用。
4.group 倉庫組:通過倉庫組的概念統(tǒng)一管理多個倉庫,在項目中請求倉庫組即可請求組中的所有倉庫。

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 包已經(jīng)導入:
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 中對應(yīng)。
3.repository 和 pluginRepository 中,ID 與我們新建的倉庫 ID對應(yīng),url 與 Nexus 生成的倉庫地址對應(yīng)。

配置完成后 maven 在獲取 jar 包時,就會從新建倉庫中獲取。

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

推薦閱讀更多精彩內(nèi)容