nexus 3 搭建私服maven倉庫


下載sonatype nexus repository manager 3.x oss版
下載地址:http://www.sonatype.com/download-oss-sonatype

安裝
windows版
進入bin目錄下執行: nexus.exe/install     此步驟會安裝nexus服務,可以到系統服務(cmd → services.msc)中查看nexus服務是否存在

遇到上述問題,拿管理員權限打開cmd,再次執行

再執行nexus.exe/run啟動

linux版
解壓縮tar xvzf nexus-3.14.0-04-unix.tar.gz
進入bin目錄  執行./nexus run

出現上圖說明啟動成功

啟動后登錄地址:http://localhost:8081
默認admin/admin123

修改端口號

默認8081端口號,如果想換一個端口號修改配置文件,經查找配置文件在    /home/tqhy/java/nexus-3.14.0-04/etc/nexus-default.properties,修改端口為8082,重啟即可。

停止nexus服務

stop命令雖然報了nexus停止的信息,但是nexus並沒有停止

tqhy@tqhy-P5K-E:~/java/nexus-3.14.0-04/bin$ ./nexus stop
Shutting down nexus
nexus is not running.

發現直接在啟動服務的終端執行ctrl+c,服務就停了,如果終端關閉,殺死nexus進程

讓所有的maven項目使用私庫
配置maven的settings.xml

  <servers>
    <server>
      <id>maven-releases</id>
      <username>admin</username>
      <password>admin123</password>
    </server>
    <server>
      <id>maven-snapshots</id>
      <username>admin</username>
      <password>admin123</password>
    </server>
  </servers>
  <mirrors>
    <mirror>
      <id>maven-public</id>
      <name>maven-public</name>
      <url>http://localhost:8081/repository/maven-public/</url>
      <mirrorOf>*</mirrorOf>
    </mirror>
  </mirrors>
  <profiles>
    <profile>
        <id>nexus</id>
      <repositories>
        <repository>
          <id>maven-central</id>
          <url>http://localhost:8081/repository/maven-central/</url>
          <releases><enabled>true</enabled></releases>
          <snapshots><enabled>true</enabled></snapshots>
        </repository>
      </repositories>
      <pluginRepositories>
        <pluginRepository>
          <id>maven-central</id>
          <url>http://localhost:8081/repository/maven-central/</url>
          <releases><enabled>true</enabled></releases>
          <snapshots><enabled>true</enabled></snapshots>
        </pluginRepository>
      </pluginRepositories>
    </profile>
  </profiles>
  <activeProfiles>
    <activeProfile>nexus</activeProfile>
  </activeProfiles>

單個項目使用私庫
配置maven的settings.xml

  <servers>
    <server>
      <id>maven-releases</id>
      <username>admin</username>
      <password>admin123</password>
    </server>
    <server>
      <id>maven-snapshots</id>
      <username>admin</username>
      <password>admin123</password>
    </server>
  </servers>
  <mirrors>
      <mirror>
      <id>maven-public</id>
      <name>maven-public</name>
      <url>http://localhost:8081/repository/maven-public/</url>
      <mirrorOf>*</mirrorOf>
    </mirror>
  </mirrors>

配置項目的pom.xml

  <distributionManagement>
      <snapshotRepository>
        <id>maven-snapshots</id>
        <url>http://localhost:8081/repository/maven-snapshots/</url>
      </snapshotRepository>
      <repository>
        <id>maven-releases</id>
        <url>http://localhost:8081/repository/maven-releases/</url>
      </repository>
  </distributionManagement>

  <repositories>
       <repository>
         <id>maven-public</id>
         <url>http://localhost:8081/repository/maven-public/</url>
       </repository>
  </repositories>

將工程導為jar包上傳到私庫
對工程執行deploy -e命令

遇到問題

1、low disk watermark...replicas will not be assigned to this node

網上說要清理磁盤空間

我當時在下載,占用很大內存,后來刪掉了,這個問題就沒了

2、Failed to transfer http://xx.xx. Error code 400, Repository version policy: RELEASE does not allow metadata in path: cn/blueboz/train/hibernate/0.0.1-SNAPSHOT/maven-metadata.xml -> [Help 1]

deploy 出現問題,是因為將部署路徑寫錯,錯誤在於建立的倉庫是RELEASE版本,上傳的jar包是SNAPSHOT版本,改成RELEASE版本就好了

參考:
https://blog.csdn.net/liumiaocn/article/details/61931847
https://blog.csdn.net/cuncaojin/article/details/81270897
https://help.sonatype.com/repomanager3/installation/installation-methods

https://blog.csdn.net/blueboz/article/details/63686679
https://www.cnblogs.com/hanhuibing/articles/5530820.html


免責聲明!

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



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