Step 1. 配置 pom.xml
<repositories>
<repository>
<id>central</id>
<name>Central Repository</name>
<url>http://search.maven.org/#browse</url>
<layout>default</layout>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>nexus</id>
<name>Nexus Repository</name>
<url>http://localhost:8081/nexus/content/groups/public</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
Step 2. 安裝 nexus
下載地址:https://www.sonatype.com/download-sonatype-trial?submissionGuid=2846484b-7042-4f2e-991f-0d4c0e5d2388
- 解壓、配置nexus端口(默認: 8081)
- 配置JDK環境變量
- 配置nexus環境變量
- cmd -> nexus install -> nexus start -> nexus started
- 打開瀏覽器:http://localhost:8081/nexus,登錄【默認:用戶名:admin,密碼:admin123】
- 配置可使用的中央倉庫地址,central -> configuration -> remote location uri=遠程中央倉庫地址
備註:
- 地址一:http://search.maven.org/#browse
- 地址二:http://repo1.maven.org/maven2/org/apache/
- 新版需要JDK7才能啓動,如果服務已經運行,啓動失敗,說明JDK版本問題;舊版可支持JDK6
Step 3. 配置 settings.xml
<mirrors>
<mirror>
<id>central</id>
<mirrorOf>central,nexus</mirrorOf>
<name>Nexus mirror to central</name>
<url>http://localhost:8081/nexus/content/groups/public</url>
</mirror>
</mirrors>