内容简介:设置多仓库有两种方法,第一种直接在项目 POM 中定义这里的 id 就是 mirrorOf 使用的 ID。第二种方法是在
多仓库配置
设置多仓库有两种方法,第一种直接在项目 POM 中定义
<project>
...
<repositories>
<repository>
<id>my-repo1</id>
<name>your custom repo</name>
<url>http://jarsm2.dyndns.dk</url>
</repository>
<repository>
<id>my-repo2</id>
<name>your custom repo</name>
<url>http://jarsm2.dyndns.dk</url>
</repository>
</repositories>
...
</project>
这里的 id 就是 mirrorOf 使用的 ID。
第二种方法是在 ~/.m2/settings.xml
文件中全局修改。
<settings>
...
<profiles>
...
<profile>
<id>myprofile</id>
<repositories>
<repository>
<id>my-repo2</id>
<name>your custom repo</name>
<url>http://jarsm2.dyndns.dk</url>
</repository>
...
</repositories>
</profile>
...
</profiles>
<activeProfiles>
<activeProfile>myprofile</activeProfile>
</activeProfiles>
...
</settings>
别忘了激活 profile,或者也可以使用 mvn 参数
mvn -Pmyprofile ...
这里提供一下 jboss 官方的配置
<profiles>
<profile>
<id>jboss</id>
<repositories>
<repository>
<id>jboss-public-repository-group</id>
<name>JBoss Public Maven Repository Group</name>
<url>https://repository.jboss.org/nexus/content/groups/public-jboss/</url>
<layout>default</layout>
<releases>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>jboss-public-repository-group</id>
<name>JBoss Public Maven Repository Group</name>
<url>https://repository.jboss.org/nexus/content/groups/public-jboss/</url>
<layout>default</layout>
<releases>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
</snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
设置镜像
设置镜像的作用是为了加快下载速度,理论上来说任何一个仓库 B 可以提供仓库 A 所有的内容,那么可以认为 B 是 A 的一个镜像,比如说 阿里提供了很多仓库的镜像 使用这些镜像可以提高下载速度。
<mirror>
<id>mirror</id>
<mirrorOf>external:*,!repo</mirrorOf>
<name>nexus repository</name>
<url>http://nexus.xxx/repository/maven-proxy</url>
</mirror>
说明:
-
id唯一标识 -
mirrorOf指定镜像规则,什么情况下从镜像仓库拉取, 官方文档* external:* repo,repo1 *,!repo1
-
name名称描述 -
url地址
使用场景
大部分情况下公司或者自用都会自建 nexus 仓库,那么首先 profile 中会配置需要的远程仓库,比如 id 为 repo
url 为 http://nexus.xxx.xxx
那么可以在 mirror 中配置 mirrorOf
<mirrorOf>repo</mirrorOf> <url>指向你自己的搭的代理</url>
这样对 repo 的所有请求都会转发给你自己的 Nexus。
mirrorOf 也有很多其他的语法,可以参考上面。
以上所述就是小编给大家介绍的《Maven 多仓库和镜像配置》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!
猜你喜欢:- 查看Docker镜像仓库中镜像的所有标签
- 搭建 Docker 镜像仓库代理
- golang包管理镜像仓库
- Docker: 上传镜像至私有仓库
- 『高级篇』docker之镜像仓库(20)
- 原 荐 Harbor仓库镜像扫描原理
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
淘宝、天猫网上开店速查速用一本通
刘珂 / 北京时代华文书局 / 2015-6 / 39.8
为了帮助众多的新手卖家掌握淘宝天猫网上开店、货源准备、店铺装修、商品拍摄、交易方法、营销推广以及售后服务等知识,本书作者根据自己多年网上开店心得,并结合了多名淘宝五皇冠店主和天猫旗舰店卖家的经验,精心策划编写了本书。 《淘宝、天猫网上开店速查速用一本通:开店、装修、运营、推广完全攻略》将目前最前沿、最流行的营销理念运用到淘宝天猫网上平台,所有技术都在实际应用获得显著效果,并且还在持续创造着惊......一起来看看 《淘宝、天猫网上开店速查速用一本通》 这本书的介绍吧!