之前寫了個項(xiàng)目提交到maven nexus私服,今天其他的項(xiàng)目需要引用這個jar包,發(fā)現(xiàn)下載失敗,于是便有了這篇文章。
方法一:
配置項(xiàng)目的pom.xml文件
<repositories>
<repository>
<id>test-nexus</id>
<name>test</name>
<url>你的私服地址</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
方法二:
配置settings.xml文件
<profiles>
<profile>
<id>nexus</id>
<repositories>
<repository>
<id>central</id>
<name>Nexus</name>
<url>你的私服地址</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<name>Nexus</name>
<url>你的私服地址</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
<!-- 配置了profile之后,需要打開配置,否則無用 -->
<activeProfiles>
<activeProfile>nexus</activeProfile>
</activeProfiles>
個人還是推薦settings.xml方式,這樣不會影響項(xiàng)目代碼,將環(huán)境配置帶入到項(xiàng)目中。