Nexus Repository 安裝及使用

Nexus Repository Manager OSS 3.x 安裝

  • 下載

https://www.sonatype.com/download-oss-sonatype 選擇對應的版本下載,以nexus-3.6.0-02-win64(https://www.sonatype.com/oss-thank-you-win64.zip)爲例;app

  • 解壓

將nexus-3.6.0-02-win64.zip解壓至對應目錄;maven

  • 執行

...\nexus-3.6.0-02-win64\nexus-3.6.0-02\bin>nexus.exe /runurl

  • 修改配置

配置文件位於:\etc\nexus-default.propertiesspa

  1. application-port=8091 內嵌Jetty對應Web服務端口號;
  2. application-host=0.0.0.0 對應Host;
  3. nexus-context-path=/nexus
  • 註冊服務(Windows Platform)

...\nexus-3.6.0-02-win64\nexus-3.6.0-02\bin>nexus.exe /install nexusorm

  • Nexus Repository Manager 管理頁面

URL:http://localhost:8091/nexus;server

點擊右上角Sign in 按鈕登陸。默認用戶名:admin,密碼:admin123;xml

點擊齒輪狀配置按鈕,進入配置頁面;ip

  • Nexus、Maven結合使用,創建本地私庫
  1. 修改Maven全局或者本地settings.xml;
  2. 或者直接配置在項目的POM文件中;

上述兩種方式都可;資源

settings.xml增長以下配置:get

<localRepository>D:\...\repository-dev</localRepository>

<mirror>
        <id>nexus-public</id>
        <mirrorOf>central</mirrorOf>
        <name>Nexus Repository</name>
        <url>http://<Host>:8091/nexus/repository/maven-public/</url>
    </mirror>

<server>
        <id>nexus-releases</id>
        <username>dev</username>
        <password>123456</password>
    </server>
    <server>
        <id>nexus-snapshot</id>
        <username>dev</username>
        <password>123456</password>
    </server>

POM 文件修改實例:

<repositories>
   <repository>
      <id>nexus-public</id>
      <name>nexus-public</name>
      <url>http://<Host>:8091/nexus/repository/maven-public/</url>
      <snapshots>
         <enabled>true</enabled>
      </snapshots>
      <releases>
         <enabled>true</enabled>
      </releases>
   </repository>
</repositories>

<distributionManagement>
   <repository>
      <id>nexus-nexus</id>
      <name>Releases</name>
      <url>http://<Host>:8091/nexus/repository/maven-releases/</url>
   </repository>
   <snapshotRepository>
      <id>nexus-nexus</id>
      <name>Snapshot</name>
      <url>http://<Host>:8091/nexus/repository/maven-snapshots/</url>
   </snapshotRepository>
</distributionManagement>

-------------------------------------------------------------------------------------------------------------

本地私庫便可從遠程倉庫下載資源了:

相關文章
相關標籤/搜索