<repositories>
<repository>
<id>jboss</id>
<name>JBoss Repository</name>
<url>https://repository.jboss.com/maven2/</url>
<releases><enabled>true</enabled><updatePolicy>daily</updatePolicy></releases>
<snapshots><enabled>false</enabled><checksumPolicy>warn</checksumPolicy></snapshots>
<layout>default</layout>
</repository>
</repositories>
關鍵元素: id 唯一標識(central 保留給中央倉庫),url 基於 HTTP,releases/snapshots 控制版本類型下載權限,updatePolicy 檢查更新頻率,checksumPolicy 校驗失敗策略。
<servers>
<server>
<id>releases</id> <!-- 必須與 repository id 一致 -->
<username>admin</username>
<password>admin123</password>
</server>
</servers>
認證信息絕不可放入 POM(POM 會提交代碼倉庫),只能放本機 settings.xml。
<distributionManagement>
<repository>
<id>releases</id>
<url>https://nexus.example.com/content/repositories/releases</url>
</repository>
<snapshotRepository>
<id>snapshots</id>
<url>https://nexus.example.com/content/repositories/snapshots</url>
</snapshotRepository>
</distributionManagement>
執行 mvn clean deploy,快照版進 snapshots,發布版進 releases。
<mirrors>
<mirror>
<id>aliyun</id>
<mirrorOf>central</mirrorOf>
<url>https://maven.aliyun.com/nexus/content/groups/public/</url>
</mirror>
</mirrors>
<mirror> <id>nexus</id> <mirrorOf>*</mirrorOf> <url>https://nexus.internal/content/groups/public/</url> </mirror>
注意: 鏡像完全屏蔽被鏡像倉庫,鏡像掛掉會導致無法下載。
https://maven.aliyun.com/nexus/content/groups/public/https://repo2.maven.org/maven2/https://repository.jboss.org/nexus/content/groups/public