maven学习九之pom.xml或settings.xml对nexus的配置
(1)在POM中配置Nexus仓库
<project>
...
<repositories>
<repository>
<id>nexus</id>
<name>Nexus</name>
<url>https://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>https://localhost:8081/nexus/content/groups/public/<url>
<release><enabled>true</enabled></release>
<snapshots><enabled>true></enabled></snapshots>
</pluginRepository>
</pluginRepositories>
...
</project>
上述配置只对当前项目有效,若需让本机所有Maven项目均使用Mavne私服,应该在setting.xml中进行配置。
(2)在setting.xml中配置Nexus仓库
<settings>
...
<profiles>
<profile>
<id>nexus</id>
<repositories>
<repository>
<id>nexus</id>
<name>Nexus</name>
<url>https://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>https://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>
activeProfiles用来激活。
(3) 配置镜像让Maven只使用私服
<settings>
...
<mirrors>
<mirror>
<id>nexus</id>
<mirrorOf>*<?mirrorOf>
<url>https://localhost:8081/nexus/content/groups/public/</url>
</mirror>
</mirrors>
<profiles>
<profile>
<id>nexus</id>
<repositories>
<repository>
<id>central</id>
<name>https://central</name>
<release><enabled>true</enabled></release>
<snapshots><enabled>true></enabled></snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<name>https://central</name>
<release><enabled>true</enabled></release>
<snapshots><enabled>true></enabled></snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
<activeProfiles>
<activeProfile>nexus</activeProfiles>
</activaProfiles>
</settings>
只要mirrorOf中的工厂需要下载jar,都会自动来找该镜像。如果镜像地址有,就下载下来。若镜像地址没有,mirrorOf中的工厂也不会到中央资源库下载,而是由镜像去下载。这是推荐的做法。若镜像下载不到,就下载失败。
原帖地址:https://springsfeng.iteye.com/blog/1456856
最后更新:2017-04-03 05:40:33
上一篇:
Junit中测试插入等无返回值的操作要注意的问题
下一篇:
文本文件和二进制文件
Joomla404页面错误怎么办?
Json拼接字符串必须用双引号
ld: warning: cannot find entry symbol _start; defaulting to 00000000080481d8
中国黑客发展历程
月费99,融资过亿,这个老阿里人做出了便利店式健身房
美CIA CherryBlossom项目暴露路由器安全问题
关于 Tomcat catalina.out 不断变大的问题
智能马桶盖在天猫卖爆,松下“盖神”掌舵后做了一个决定......
AliCDN,盛开在云端的花朵
【收藏】首份《顶级数据团队建设全景报告》重磅发布: 逾半数据团队称人才储备不足