1.在pom.xml文件中配置需要發布的工廠
如果想把項目發布到nexus中,需要在pom.xml中配置releases和snapshots版本發布的具體repository
<distributionManagement>
<!-- 兩個ID必須與setting.xml中的<server><id>nexus-releases</id></server>保持一致-->
<repository>
<id>nexus-releases</id>
<name>Nexus Release Repository</name>
<url>http://localhost:8081/nexus/content/repositories/releases</url>
</repository>
<snapshotRepository>
<id>nexus-snapshots</id>
<name>Nexus Snapshot Repository</name>
<url>http://localhost:8081/nexus/content/repositories/snapshots</url>
</snapshotRepository>
</distributionManagement>
2.給用戶授權,讓其有權發布項目
在Maven的conf中的setting.xml文件中,找到servers標簽,添加相應的用戶。進行授權
這里的id需要和pom.xml中的id一樣
<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>
</servers>
這里配置的是admin用戶,因為admin是管理員用戶。是有權限發布的。
假如你配置的是deploy用戶,需要給deploy用戶授權。
3.發布到nexus中
使用mvn:deploy 命令發布到nexus中
發布成功后,可以在repositories中的releases或者snapshots中看到剛剛發布的項目
1.Nexus安裝與配置
2.Nexus更新索引
3.發布Maven項目到nexus中
4.按項目類型分配不同的nexus工廠來發布不同的項目

