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>