Maven相关名词、概念-解释总结

本文介绍了Maven的仓库管理机制,包括中央库、本地库和远程仓库的概念及配置方式,并详细阐述了依赖机制的工作流程。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1.repository

       1.1 中央库

maven官方的repository。体现在  %MAVEN_HOME%/conf/setting.xml中的  <mirrors><mirror>  …</mirror>  </mirrors>
  <mirrors>
    <!-- mirror
     | Specifies a repository mirror site to use instead of a given repository. The repository that
     | this mirror serves has an ID that matches the mirrorOf element of this mirror. IDs are used
     | for inheritance and direct lookup purposes, and must be unique across the set of mirrors.
     |
    <mirror>
      <id>mirrorId</id>
      <mirrorOf>repositoryId</mirrorOf>
      <name>Human Readable Name for this Mirror.</name>
      <url>http://my.repository.com/repo/path</url>
    </mirror>
	 -->
	 <mirror>
		<id>CN</id>
		<name>OSChina Central</name>                                            
		<url>http://maven.oschina.net/content/groups/public/</url>
		<mirrorOf>central</mirrorOf>
	</mirror>
  </mirrors>

          1.2本地库

在自己机器上存储的,让maven管理的jar包的库。体现在体现在  %MAVEN_HOME%/conf/setting.xml中的<localRepository>
  <!-- localRepository
   | The path to the local repository maven will use to store artifacts.
   |
   | Default: ${user.home}/.m2/repository
     -->
  <localRepository>F:/mvnRepository</localRepository>

1.3远程仓库

有的jar包不在中央库中存储------存储在另一个组织搭建的库中就需要指定远程仓库   体现在  pom.xml文件中    
<project ...>
        <repositories>
      <repository>
	<id>JBoss repository</id>
	<url>http://repository.jboss.org/nexus/content/groups/public/</url>
      </repository>
    </repositories>
</project>
1.4依赖机制
当某jar被引用-----加入到 <dependency>  ……</dependency> 中时maven会默认执行以下顺序进行依赖的添加:
在 Maven 的本地仓库搜索 xxx
在 Maven 中央存储库搜索 xxx
在 Maven 远程仓库搜索 xxx(如果在 pom.xml 中定义)
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值