溫馨提示×

溫馨提示×

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

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

Nexus Repository Manager的應用

發布時間:2020-02-29 20:27:51 來源:網絡 閱讀:438 作者:mybabe0312 欄目:軟件技術

安裝和運行Nexus Repository Manager很簡單。您可以將存檔文件解壓縮到您有完全訪問權限的目錄中,也可以使用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的應用

2, 解壓

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

Nexus Repository Manager的應用

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

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

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

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

6, 啟動

./nexus run

使用run會使nexus在當前shell中運行。也可以使用start, stop, restart, force-reload 和status 指令。
Nexus Repository Manager的應用

7,訪問
Nexus Repository Manager的應用

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

Nexus Repository Manager的應用

Nexus Repository Manager的應用

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

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

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

8,倉庫的操作

Nexus Repository Manager的應用

Nexus Repository Manager的應用

Nexus Repository Manager的應用

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

<settings>
  <mirrors>
            <!—配置一個鏡像用于替代中央倉庫 -->
            <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)編輯項目下的pom.xml文件

    <!-- 遠程倉庫地址 -->
    <pluginRepositories>
        <pluginRepository>
            <id>nexus</id>
            <name>Team Nexus Repository</name>
            <url>http://192.168.30.161:8081/repository/maven-public/</url>
        </pluginRepository>
    </pluginRepositories>
   <!-- 配置遠程發布到私服,mvn deploy -->
    <distributionManagement>
        <!-- 定義releases庫的坐標 -->
        <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時只上傳jar包到遠程倉庫的配置 -->
            <plugin>
                <artifactId>maven-deploy-plugin</artifactId>
                <version>2.7</version>
                 <configuration>
                                    <!-- 更新元數據 -->
                                    <updateReleaseInfo>true</updateReleaseInfo>
                                </configuration>
                <executions>
                    <execution>
                        <id>default-deploy</id>
                        <phase>deploy</phase>
                        <goals>
                            <goal>deploy</goal>
                        </goals>
                        <!-- skip默認deploy插件的執行 -->
                        <configuration>
                            <skip>true</skip>
                        </configuration>
                    </execution>
                    <execution>
                        <id>deploy-file</id>
                        <phase>deploy</phase>
                        <goals>
                            <goal>deploy-file</goal>
                        </goals>
                        <configuration>
                            <!-- 開發階段上傳到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問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

亚洲午夜精品一区二区_中文无码日韩欧免_久久香蕉精品视频_欧美主播一区二区三区美女