Maven仓库,私有仓库的设置(在 中配置远程仓库)
1: 索引更新:将下载的包中替换 D:\Nexus\sonatype-work\nexus\indexer\central-ctx
如果工厂换了,那么索引页需要更换
2: 配置镜像,覆盖*仓库的默认地址
<mirrors>
<mirror>
<id>central</id>
<mirrorOf>nexus</mirrorOf><!--如果想为所有的仓库做镜像那么可以改为:<mirrorOf>*</mirrorOf>-->
<name>Human Readable Name for this Mirror.</name>
<url>http://127.0.0.1:8081/nexus/content/groups/public/</url>
</mirror>
</mirros>
文件中的配置为(在不修改默认配置的情况下):
<repository>
<id>nexus</id>
<name>nexus repository</name>
<url>http://127.0.0.1:8081/nexus/content/groups/public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
这就表示我们项目中所有的依赖不会到文件中的url中找了,而是会倒我们镜像中配置的url中找,
两者之间是通过id来进行一一对应关联的
3: 如果我们将我们项目pom里面的仓库设置删除、那么我们有一个默认的仓库设置,但是不支持快照版的发布,
如果我们修改这一默认的配置,就得使用profile。如下配置:
在我们本地仓库的文件中:
<profiles>
<profile>
<id>central-repos</id>
<repositories>
<repository>
<id>central</id>
<name>Central</name>
<url>http://central</url><!--这个地址无效,因为我们为所有的仓库配置了镜像-->
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
</profile>
<activeProfiles>
<activeProfile>central-repos</activeProfile>
</activeProfiles>
4: 通过以上配置之后我们就可以在nexus上来搜索我们的项目依赖了,而不用去其他的网上maven仓库中查找