溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

Nexus Repository Manager的應(yīng)用

發(fā)布時(shí)間:2020-02-29 20:27:51 來源:網(wǎng)絡(luò) 閱讀:380 作者:mybabe0312 欄目:軟件技術(shù)

安裝和運(yùn)行Nexus Repository Manager很簡單。您可以將存檔文件解壓縮到您有完全訪問權(quán)限的目錄中,也可以使用Docker映像安裝它。

安裝包下載:https://help.sonatype.com/repomanager3/download
安裝參考文檔:https://help.sonatype.com/repomanager3

1, 下載安裝包
https://help.sonatype.com/repomanager3/download/download-archives---repository-manager-3

wget https://download.sonatype.com/nexus/3/latest-unix.tar.gz

Nexus Repository Manager的應(yīng)用

2, 解壓

tar xvzf nexus-3.19.1-01-unix.tar.gz

Nexus Repository Manager的應(yīng)用

3, 修改默認(rèn)的配置文件(etc/nexus-default.properties) 【可選】
Nexus Repository Manager的應(yīng)用
這里主要用于修改端口號(hào)

4, 修改默認(rèn)配置(bin/nexus.vmoptions)【可選】
Nexus Repository Manager的應(yīng)用
一般情況下是不需要修改的。

5, 修改jdk配置【可選】
可以編輯bin/nexus腳本,找到“INSTALL4J_JAVA_HOME_OVERRIDE”,刪除哈希并指定JDK/JRE的位置。
Nexus Repository Manager的應(yīng)用
例如:

INSTALL4J_JAVA_HOME_OVERRIDE=/usr/lib/jvm/openjdk-8

6, 啟動(dòng)

./nexus run

使用run會(huì)使nexus在當(dāng)前shell中運(yùn)行。也可以使用start, stop, restart, force-reload 和status 指令。
Nexus Repository Manager的應(yīng)用

7,訪問
Nexus Repository Manager的應(yīng)用

Nexus Repository Manager的應(yīng)用
登錄密碼在文件/data/sonatype/sonatype-work/nexus3/admin.password中。
Nexus Repository Manager的應(yīng)用
Nexus Repository Manager的應(yīng)用
Nexus Repository Manager的應(yīng)用
Nexus Repository Manager的應(yīng)用
默認(rèn)情況下,啟用匿名訪問將允許未經(jīng)身份驗(yàn)證的下載、瀏覽和搜索存儲(chǔ)庫內(nèi)容??梢酝ㄟ^編輯分配給匿名用戶的角色來更改未經(jīng)身份驗(yàn)證用戶的權(quán)限。

Nexus Repository Manager的應(yīng)用

Nexus Repository Manager的應(yīng)用

Type列說明:
1) Proxy
默認(rèn)創(chuàng)建了一個(gè)通過HTTPS訪問中央倉庫(https://repo1.maven.org/maven2/)的代理存儲(chǔ)庫。為了減少重復(fù)下載并提高開發(fā)人員和CI服務(wù)器的下載速度,還應(yīng)該將訪問的所有其他遠(yuǎn)程存儲(chǔ)庫代理為代理存儲(chǔ)庫。

2) hosted
hosted Maven repository可用于部署自己的組件和第三方組件。默認(rèn)情況下,創(chuàng)建了兩個(gè)hosted Maven庫,分別是maven-releases與maven-snapshots。一個(gè)用于發(fā)布版本策略,一個(gè)用于快照版本策略。

3) group
存儲(chǔ)庫組允許您使用一個(gè)URL公開多個(gè)代理和托管存儲(chǔ)庫以及其他存儲(chǔ)庫組的聚合內(nèi)容以進(jìn)行工具配置。建議使用存儲(chǔ)庫組將所有Maven存儲(chǔ)庫從存儲(chǔ)庫管理器公開給用戶,而無需進(jìn)一步的客戶端配置。

8,倉庫的操作

Nexus Repository Manager的應(yīng)用

Nexus Repository Manager的應(yīng)用

Nexus Repository Manager的應(yīng)用

9,Maven中使用
1)編輯Maven的setting.xml文件

<settings>
  <mirrors>
            <!—配置一個(gè)鏡像用于替代中央倉庫 -->
            <mirror>
                <id>nexus</id>
                <name>nexus</name>
                <url>http://192.168.30.161:8081/repository/maven-public/</url>
                <mirrorOf>*</mirrorOf> 
            </mirror>
  </mirrors>
  <servers>
            <server>
                <id>nexus</id>
                <username>admin</username>
                <password>123456</password>
            </server>
            <server>
                <id>realeases</id>
                <username>admin</username>
                <password>123456</password>
            </server>
            <server>
                <id>snapshots</id>
                <username>admin</username>
                <password>123456</password>
            </server>
  </servers>
</settings>

2)編輯項(xiàng)目下的pom.xml文件

    <!-- 遠(yuǎn)程倉庫地址 -->
    <pluginRepositories>
        <pluginRepository>
            <id>nexus</id>
            <name>Team Nexus Repository</name>
            <url>http://192.168.30.161:8081/repository/maven-public/</url>
        </pluginRepository>
    </pluginRepositories>
   <!-- 配置遠(yuǎn)程發(fā)布到私服,mvn deploy -->
    <distributionManagement>
        <!-- 定義releases庫的坐標(biāo) -->
        <repository>
            <id>releases</id>
            <name>Nexus Release Repository</name>
            <url>http://192.168.30.161:8081/repository/maven-releases/</url>
        </repository>
        <!-- 定義snapshots庫 -->
        <snapshotRepository>
            <id>snapshots</id>
            <name>Nexus Snapshot Repository</name>
            <url>http://192.168.30.161:8081/repository/maven-snapshots/</url>
        </snapshotRepository>
    </distributionManagement>

插件

<!-- deploy時(shí)只上傳jar包到遠(yuǎn)程倉庫的配置 -->
            <plugin>
                <artifactId>maven-deploy-plugin</artifactId>
                <version>2.7</version>
                 <configuration>
                                    <!-- 更新元數(shù)據(jù) -->
                                    <updateReleaseInfo>true</updateReleaseInfo>
                                </configuration>
                <executions>
                    <execution>
                        <id>default-deploy</id>
                        <phase>deploy</phase>
                        <goals>
                            <goal>deploy</goal>
                        </goals>
                        <!-- skip默認(rèn)deploy插件的執(zhí)行 -->
                        <configuration>
                            <skip>true</skip>
                        </configuration>
                    </execution>
                    <execution>
                        <id>deploy-file</id>
                        <phase>deploy</phase>
                        <goals>
                            <goal>deploy-file</goal>
                        </goals>
                        <configuration>
                            <!-- 開發(fā)階段上傳到snapshot倉庫,上線階段上傳到release倉庫 -->
                            <repositoryId>${project.distributionManagement.snapshotRepository.id}</repositoryId>
                            <url>${project.distributionManagement.snapshotRepository.url}</url>
                            <file>${project.build.directory}/${project.artifactId}-${project.version}.jar</file>
                            <groupId>${project.groupId}</groupId>
                            <artifactId>${project.artifactId}</artifactId>
                            <version>${project.version}</version>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

如此,通過mvm deploy就可以將jar包上傳到私服倉庫下。

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請(qǐng)聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI