当前位置: 首页 > article >正文

maven中的仓库的配置与优先级

文章目录

  • 1 仓库的具体配置
    • 1.1 settings.xml配置本地仓库
    • 1.2 pom.xml配置的仓库
    • 1.3 settings.xml配置mirror镜像
    • 1.4 settings.xml配置profile仓库
  • 2 结论
    • 2.1 mirror中不代理`*`的拉取顺序
    • 2.2 mirror中代理了`*`的拉取顺序

1 仓库的具体配置

1.1 settings.xml配置本地仓库

<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
	<!-- localRepository
   | The path to the local repository maven will use to store artifacts.
   |
   | Default: ${user.home}/.m2/repository
  <localRepository>/path/to/local/repo</localRepository>
  -->
	<localRepository>D:\Program Files\apache-maven-3.6.3\conf\repository</localRepository>
</settings>

1.2 pom.xml配置的仓库

<project>
    <repositories>
        <repository>
            <id>com.e-iceblue</id>
            <name>e-iceblue</name>
            <url>https://repo.e-iceblue.com/nexus/content/groups/public/</url>
        </repository>
    </repositories>
</project>

1.3 settings.xml配置mirror镜像

<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
	<mirrors>
		<mirror>
			<id>aliyun-central</id>
			<name>aliyun-central</name>
			<mirrorOf>central</mirrorOf>
			<url>https://maven.aliyun.com/repository/central</url>
		</mirror>
		<mirror>
			<id>aliyun-spring</id>
			<name>aliyun-spring</name>
			<mirrorOf>spring</mirrorOf>
			<url>https://maven.aliyun.com/repository/spring</url>
		</mirror>
		<mirror>
			<id>aliyun-spring-plugin</id>
			<name>aliyun-spring-plugin</name>
			<mirrorOf>spring-plugin</mirrorOf>
			<url>https://maven.aliyun.com/repository/spring-plugin</url>
		</mirror>
	</mirrors>
</settings>

1.4 settings.xml配置profile仓库

<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
	<servers>
		<server>
			<id>nexus-server</id>
			<username>uname</username>
			<password>pwd</password>
		</server>
	</servers>
	
	<profiles>
		<profile>
			<id>nexus</id>
			<repositories>
				<repository>
					<id>nexus-server</id>
					<name>Nexus Repository</name>
					<url>https://maven.nexus.com/repository/maven-public/</url>
					<snapshots>
						<enabled>true</enabled>
						<updatePolicy>always</updatePolicy>
					</snapshots>
				</repository>
			</repositories>
		</profile>
	</profiles>

	<!--让配置生效-->
	<activeProfiles>
		<activeProfile>nexus</activeProfile>
	</activeProfiles>
</settings>

2 结论

2.1 mirror中不代理*的拉取顺序

  1. settings.xml->本地仓库,如果没有则向下找
  2. settings.xml->profile中的仓库,如果没有则向下找
  3. pom.xml配置的仓库,如果没有则向下找
  4. settings.xml->mirror中代理central的仓库

2.2 mirror中代理了*的拉取顺序

mirror中一旦代理了*,则该配置优先级最高,其他的都不会走了。
但是有一种情况除外,就是mirror中代理了central仓库,那么如果代理*的 mirror中没有,则会找代理的central仓库

  1. settings.xml->本地仓库,如果没有则向下找
  2. settings.xml->mirror中代理*的仓库,如果没有则向下找
  3. settings.xml->mirror中代理central的仓库

http://www.kler.cn/news/305054.html

相关文章:

  • 287. 寻找重复数(stl法)
  • 滚雪球学SpringCloud[2.3]:服务发现与负载均衡详解
  • 电机驱动开发之主控板
  • Docker 安装配置和基本命令详解以及案例示范
  • Java之ArrayList
  • 【组件】WEB前端-富文本编辑器组件推荐 在线编辑器 Word
  • 了解线程池
  • 【文献阅读】Unsupervised Machine Learning for Bot Detection on Twitter
  • pytorch qwen2-vl自定义数据全量微调
  • SpringBoot万级并发-jemeter-Address already in use: connect
  • 三、Kubernetes中的控制器的使用
  • AI服务器,深度学习英特尔服务器主板和超微服务器主板哪个牌子好?
  • Rust 函数
  • 人工智能物联网的去中心化和分布式学习:全面综述、新兴挑战和机遇
  • 基于鸿蒙API10的RTSP播放器(七:亮度调节功能测试)
  • 太速科技-基于XC7Z100+AD9361的双收双发无线电射频板卡
  • 【2024】前端学习笔记6-容器标签div
  • QT实现TCP/UDP通信
  • 基于python+django+vue的农产品销售管理系统
  • django-admin自定义功能按钮样式
  • medium_socnet
  • 数据库与表的操作
  • 2024秋季云曦开学考
  • 商业预测 初识R
  • 数据结构基础详解:哈希表【理论计算篇】开放地址法_线性探测法_拉链法详解
  • 文件管理系统DCC与泛微OA系统集成案例
  • JVM面试真题总结(十)
  • HarmonyOS开发者基础认证试题
  • CSP-J阅读程序专题第二题 - 2
  • 回溯——12.N皇后