(1)在POM中配置Nexus仓库spring
<project>
...
<repositories>
<repository>
<id>nexus</id>
<name>Nexus</name>
<url>http://localhost:8081/nexus/content/groups/public/<url>
<release><enabled>true</enabled></release>
<snapshots><enabled>true></enabled></snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>nexus</id>
<name>Nexus</name>
<url>http://localhost:8081/nexus/content/groups/public/<url>
<release><enabled>true</enabled></release>
<snapshots><enabled>true></enabled></snapshots>
</pluginRepository>
</pluginRepositories>
...
</project>
ide
上述配置只对当前项目有效,若需让本机全部Maven项目均使用Mavne私服,应该在setting.xml中进行配置。
url
(2)在setting.xml中配置Nexus仓库spa
<settings>
...
<profiles>
<profile>
<id>nexus</id>
<repositories>
<repository>
<id>nexus</id>
<name>Nexus</name>
<url>http://localhost:8081/nexus/content/groups/public/<url>
<release><enabled>true</enabled></release>
<snapshots><enabled>true></enabled></snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>nexus</id>
<name>Nexus</name>
<url>http://localhost:8081/nexus/content/groups/public/<url>
<release><enabled>true</enabled></release>
<snapshots><enabled>true></enabled></snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
<activeProfiles>
<activeProfile>nexus</activeProfiles>
</activaProfiles>
...
</settings>xml
activeProfiles用来激活私服blog
(3) 配置镜像让Maven只使用私服
资源
<settings>
...
<mirrors>
<mirror>
<id>nexus</id>
<mirrorOf>*<?mirrorOf>
<url>http://localhost:8081/nexus/content/groups/public/</url>
</mirror>
</mirrors>
<profiles>
<profile>
<id>nexus</id>
<repositories>
<repository>
<id>central</id>
<name>http://central</name>
<release><enabled>true</enabled></release>
<snapshots><enabled>true></enabled></snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<name>http://central</name>
<release><enabled>true</enabled></release>
<snapshots><enabled>true></enabled></snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
<activeProfiles>
<activeProfile>nexus</activeProfiles>
</activaProfiles>
...
</settings>get
只要mirrorOf中的工厂须要下载jar,都会自动来找该镜像。若是镜像地址有,就下载下来。若镜像地址没有,mirrorOf中的工厂也不会到中央资源库下载,而是由镜像去下载。这是推荐的作法。若镜像下载不到,就下载失败。it