搭建Nexus本地倉庫


1 下載nexus安裝包  網址:http://www.sonatype.org/nexus/
   建議下載最新的版本,最新的版本支持比較新的jdk版本, 1.6 肯定是不行的,必須是1.7及其以上。

下載所需安裝包。http://pan.baidu.com/s/1ntzDWkL
如果讀者已經設置jdk 版本,且低於1.7. 則可以配置想要使用的 jdk 版本。 nexus-2.10.0-02\bin\jsw\conf, 目錄 wrapper.conf 文件 ,
找到 wrapper.java.command= F:/jdk1.7.0_71/bin/java.exe, 這樣配置即可。
2 啟動nexus服務
找到當前對應的版本,有32, 64 位。
    進入nexus的文件目錄:..\nexus-2.10.0-02\bin\jsw\windows-x86-64下面,
      Installnexus.bat 表示安裝nexus服務到window服務中去。
      Startnexus.bat  表示啟動nexus服務。
      nexus.bat  表示啟動nexus應用程序 。
      Resumenexus.bat  表示重啟nexus 。
      Stopnexus.bat  表示停止nexus服務
   啟動nexus 無需啟動tomcat,只需要點擊“nexus.bat "就可以啟動。
   啟動成功后 在瀏覽器地址欄中輸入:
   http://localhost:8081/nexus/index.html
   如果看到nexus界面 說明啟動成功。
3 設置maven的setting.xml文件
   3.1 設置自定義的倉庫
   默認倉庫會保存在c盤的C:\Users\yjx\.m2下面,如果要使用自定義的倉庫,則在setting.xml中添加下面的配置

<localRepository>e:/repository</localRepository>

 3.2 設置鏡像私服

?

1

2

3

4

5

6

7

8

9

10

11

12

13

14

<mirrors>

   <!-- mirror

    | Specifies a repository mirror site to use instead of a given repository. The repository that

    | this mirror serves has an ID that matches the mirrorOf element of this mirror. IDs are used

    | for inheritance and direct lookup purposes, and must be unique across the set of mirrors.

    |-->

   <mirror>

     <id>nexus</id>

     <mirrorOf>*</mirrorOf>

     <name>Nexus Mirror</name>

     <url>http://localhost:8081/nexus/content/groups/public</url>

   </mirror>

     

 </mirrors>

3.3 設置 profile

  

?

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

<profile>

      <id>nexus</id>

      <repositories>

        <repository>

          <id>nexus</id>

          <name>Nexus</name>

          <url>http://localhost:8081/nexus/content/groups/public</url>

          <releases><enabled>true</enabled></releases>

          <snapshots><enabled>true</enabled></snapshots>

        </repository>

      </repositories>

      <pluginRepositories>

        <pluginRepository>

          <id>nexus</id>

          <name>Nexus</name> 

          <url>http://localhost:8081/nexus/content/groups/public</url>

          <releases><enabled>true</enabled></releases>

          <snapshots><enabled>true</enabled></snapshots>       

        </pluginRepository>       

      </pluginRepositories>

    </profile> 

    <!--激活配置-->

    <activeProfiles>

        <activeProfile>nexus</activeProfile>

    </activeProfiles>

 

保存文件。

4 登錄nexus  用戶名admin  密碼 admin123.

  進入Repository菜單,修改 Apache Snapshots,Codehaus Snapshots,Maven Central的Download Remote indexs 為true.

  並右擊每一個倉庫的 repair Index  ,進行更新index  並把所有的proxy類型的倉庫添加到public repository中去。

  自己覺得比較好的其他的代理倉庫如下:

  添加新的repository 即代理倉庫, 代理倉庫的remoteurl

  http://repository.jboss.org/nexus/content/groups/public/

  https://repository.jboss.org/nexus/content/groups/developer/

 6 備注

   如果你安裝的jdk是1.7的版本或者更高,請使用nexus版本2.0以上的版本

 7 nexus 服務器的遷移

nexus 他本身會吧要下載好的jar 包存儲起來,下次就不會再去下載。

他的storage 存儲目錄是: sonatype-work\nexus\storage

sonatype-work 這個目錄和 nexus 是同級的,nexus-2.10.0-02 與   onatype-work 在同一目錄下,是自動創建的,遷移的時候只需要拷貝這些 storage 過去就可以了。

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM