搭建自己的maven私服
阿新 • • 發佈:2018-12-13
1. 下載nexus 下載地址: https://www.sonatype.com/download-oss-sonatype 2. 啟動對應版本的nexus …/nexus-2.14.8-01-bundle\nexus-2.14.8-01\bin\jsw 3. 訪問nexus http://localhost:8081/nexus 預設使用者名稱/密碼 : admin/admin123 type表示倉庫型別:
型別 | 用途 |
---|---|
hosted | 表示當前開發人員上傳的,包括snapshots快照版本/releases穩定版本/3rd party第三方包三種倉庫;表示當前開發人員上傳的,包括snapshots快照版本/releases穩定版本/3rd party第三方包三種倉庫; |
proxy | 表示中央服倉庫,包括snapshots快照版本/releases穩定版本兩種倉庫; |
舉個例子就是, 你上傳jar包時,release版本就會上儲存到hosted的releases倉庫,snapshot版本就會儲存到hosted的snapshots倉庫; 你下載jar包時,就回到中央倉庫找;
4. 初始化nexus 剛啟動的nexus是搜不到jar包資訊的,需要從中央倉庫同步先 選中central倉庫—>tab頁中選中configuration---->download remote indexs 選擇true 選擇完後,nexus會建立一個任務從中央倉庫同步jar包索引,耗時一兩個小時; 5. 上傳jar包
<servers> <server> <id>nexus-releases</id> <username>admin</username> <password>admin123</password> </server> <server> <id>nexus-snapshots</id> <username>admin</username> <password>admin123</password> </server>
b)專案的pom.xml中配置nexus的地址資訊,此處id必須和settings中的id對應
<distributionManagement>
<repository>
<id>nexus-releases</id>
<name>nexus releases repository</name>
<url>http://localhost:8081/nexus/content/repositories/releases/</url>
</repository>
<snapshotRepository>
<id>nexus-snapshots</id>
<name>nexus snapshotRepository</name>
<url>http://localhost:8081/nexus/content/repositories/snapshots/</url>
</snapshotRepository>
</distributionManagement>
c) deploy jar包
6. 下載jar包 maven的settings.xml檔案中配置 content/groups/public倉庫表示同時可以從proxy/hosted倉庫獲取jar包
<profiles>
<profile>
<id>dev</id>
<repositories>
<repository>
<id>public</id>
<name>public repository</name>
<url>http://ip:8081/nexus/content/groups/public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
</profile>
</profiles>
<activeProfiles>
<activeProfile>dev</activeProfile>
</activeProfiles>