第一步:在 LAN 中的服务器上安装 nexus。它非常棒——易于安装(真的,只需几分钟!)并且坚固。我们有大约 50 名工程师和许多 CI 服务器整天敲打它,它已经稳定了好几个月。假设您将它安装在 DNS 中名为“nexus.local”的服务器上。
第二步:从http://www.sonatype.com/books/nexus-book/reference/maven-sect-single-group.html复制 settings.xml ,根据需要修复主机名,将其提交到您的源代码系统,并告诉所有开发人员将其复制到他们的 ~/.m2/settings.xml 中。
第三步:正确设置项目的 pom.xml。您将需要一个定义“distributionManagement”部分的“父 POM”,如下所示:
<distributionManagement>
<snapshotRepository>
<id>nexusSS</id>
<name>Nexus Snapshot Repository</name>
<url>http://nexus.local:8081/nexus/content/repositories/snapshots</url>
</snapshotRepository>
<repository>
<id>nexusRelease</id>
<name>Nexus Release Repository</name>
<url>http://nexus.local:8081/nexus/content/repositories/releases</url>
</repository>
</distributionManagement>
第四步:启用“mvn deploy”——进入你的nexus UI(类似http://nexus.local:8081/nexus),点击users,点击“deployment”,然后给它一个密码。然后编辑你的~/.m2/settings.xml 并添加:
<settings>
...
<servers>
<server>
<id>nexus</id>
<username>deployment</username>
<password>PASSWORD</password>
</server>
</servers>
</settings>
通过运行“mvn deploy”检查它是否有效,并且您应该已将项目的工件安装到 nexus 中。
第五步:阅读 maven 的优秀文档:http: //www.sonatype.com/products/maven/documentation/book-defguide