概述
maven中心储存库
For maven to download the required artifacts of the build and dependencies (jar files) and other plugins which are configured as part of any project, there should be a common place where all such artifacts are placed. This common shared area is called as Repository in maven.
为了使maven下载构建所需的构件和依赖项(jar文件)以及配置为任何项目一部分的其他插件,应该在所有放置这些构件的公共位置放置一个。 这个公共共享区域在Maven中称为“ 存储库” 。
In maven, repositories are classified into 3 main categories as shown below :
在Maven中,存储库分为3个主要类别,如下所示:
Local Repository
本地存储库
Remote Repository
远程仓库
Central Repository
中央储存库
本地存储库 (Local Repository)
The repository which resides in our local machine which are cached from the remote/central repository downloads and ready for the usage. The folder to hold/place all the dependencies in local can be configured in the settings.xml file of the maven folder under the tag <localRepository>
.
驻留在我们本地计算机中的存储库,该存储库是从远程/中央存储库下载中缓存的,并可供使用。 可以在标记为<localRepository>
的maven文件夹的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>D:/m2repo</localRepository>
</settings>
远程仓库 (Remote Repository)
This repository as the name suggests resides in the remote server and which can be accessed by using different file transfer protocols like file://
or http://
. Remote repository will be used for both downloading and uploading the dependencies and artifacts.
顾名思义,该存储库位于远程服务器中,可以通过使用不同的文件传输协议(例如file://
或http://
。 远程存储库将用于下载和上传依赖项和工件。
<repositories>
<repository>
<id>remote.repository</id>
<url>http://download.ogrname.com/maven2/</url>
</repository>
</repositories>
中央储存库 (Central Repository)
This is the repository provided by maven community. This repository contains large set of commonly used/required libraries for any java project. Basically, internet connection is required if developers want to make use of this central repository. But, no configuration is required for accessing this central repository.
这是Maven社区提供的存储库。 该存储库包含任何Java项目的大量常用/必需库。 基本上,如果开发人员要使用此中央存储库,则需要Internet连接。 但是,访问此中央存储库不需要任何配置。
<repositories>
<repository>
<id>central.repository</id>
<url>http://repo1.maven.org/maven2/</url>
</repository>
</repositories>
本地和远程/中央存储库的组织 (Organization of Local and Remote/Central Repositories)
In the picture below you can see the organization of local and remote/central repositories.
在下面的图片中,您可以看到本地和远程/中央存储库的组织。
Maven如何搜索依赖项? (How does Maven searches for Dependencies?)
Basically, when maven starts executing the build commands, maven starts for searching the dependencies as explained below :
基本上,当maven开始执行构建命令时,maven开始搜索依赖项,如下所述:
It scans through the local repositories for all the configured dependencies. If found, then it continues with the further execution. If the configured dependencies are not found in the local repository, then it scans through the central repository.
它在本地存储库中扫描所有已配置的依赖项。 如果找到,则继续执行进一步的操作。 如果在本地存储库中找不到配置的依赖项,则它将扫描中央存储库。
If the specified dependencies are found in the central repository, then those dependencies are downloaded to the local repository for the future reference and usage. If not found, then maven starts scanning into the remote repositories.
如果在中央存储库中找到指定的依赖项,则这些依赖项将下载到本地存储库中,以备将来参考和使用。 如果未找到,则maven开始扫描到远程存储库。
If no remote repository has been configured, then maven will throw an exception saying not able to find the dependencies & stops processing. If found, then those dependencies are downloaded to the local repository for the future reference and usage.
如果未配置任何远程存储库,则maven将抛出异常,提示无法找到依赖项并停止处理。 如果找到,则将那些依赖项下载到本地存储库,以备将来参考和使用。
翻译自: https://www.studytonight.com/maven/repositories-in-maven
maven中心储存库
最后
以上就是个性硬币为你收集整理的maven中心储存库_Maven中的存储库是什么?的全部内容,希望文章能够帮你解决maven中心储存库_Maven中的存储库是什么?所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复