本文共 3852 字,大约阅读时间需要 12 分钟。
简要说明下maven的作用
A maven repository is a central location that holds build artifacts and their metadata.
Maven存储库是存放构建工件及其元数据的中央位置。
There are two types of maven repositories.
Maven存储库有两种类型。
It’s a directory in your system where you are running maven commands. It holds the artifacts downloaded from the remote repositories. When we run a maven build, the required artifacts are downloaded from the remote repository and stored in the local repository to use.
这是您系统中运行maven命令的目录。 它包含从远程存储库下载的工件。 当我们运行Maven构建时,所需的工件从远程存储库下载并存储在本地存储库中以供使用。
Maven Local repository also holds the artifacts you build in the local system with the “install” goal. The build artifacts and their metadata are copied to the local repository.
Maven Local存储库还保存您以“安装”目标在本地系统中构建的工件。 构建工件及其元数据将复制到本地存储库。
The default location of the local repository is ${user.home}/.m2/repository. But, we can change that by specifying a different location in the maven settings.xml file.
本地存储库的默认位置为$ {user.home} /。m2 / repository 。 但是,我们可以通过在maven settings.xml文件中指定其他位置来更改它。
/path/to/local/repository
These are the repositories accessed with http
or file
protocol. They are on a remote system and holds artifacts from third-party libraries.
这些是使用http
或file
协议访问的存储库。 它们位于远程系统上,并保存来自第三方库的工件。
When we build a maven project, the artifacts from the remote repository are downloaded to the local repository.
当我们构建一个Maven项目时,来自远程存储库的工件被下载到本地存储库。
When we build a maven project with the “deploy” goal, the artifact is uploaded to the remote repository.
当我们以“部署”目标构建Maven项目时,工件会上传到远程存储库。
The remote repositories can be classified into two types:
远程存储库可分为两种类型:
While working in an Enterprise environment, connecting to the internet to download dependencies is not acceptable for security, speed or bandwidth reasons. It’s advisable to set up an internal repository to keep the artifacts and publish the private artifacts.
在企业环境中工作时,出于安全性,速度或带宽的原因,无法连接到Internet以下载依赖项。 建议设置一个内部存储库以保留工件并发布私有工件。
An internal remote repository is generally accessed over the internet. Generally, the artifacts are downloaded from the central repository and cached to this repository as and when required by the internal projects.
内部远程存储库通常通过Internet访问。 通常,在内部项目需要时,从中央存储库下载工件并将其缓存到此存储库。
Maven Central repository contains the open-source artifacts. These are artifacts that are used by everyone. Anyone can access the central repository and download the artifacts. However, you need to get an account to publish your artifacts to the central repository.
Maven Central存储库包含开源工件。 这些是每个人都使用的工件。 任何人都可以访问中央存储库并下载工件。 但是,您需要获得一个帐户才能将工件发布到中央存储库。
When a maven project is built, the required dependencies are searched in the following order.
构建Maven项目时,将按以下顺序搜索所需的依赖项。
If the dependencies are not found, the build fails with an unknown dependency error.
如果找不到依赖项,则构建将失败,并出现未知的依赖项错误。
Maven knows about the local repository and the central repository. But, it doesn’t know about any custom remote repository that you might have setup. You can provide details about that in the pom.xml file.
Maven知道本地存储库和中央存储库。 但是,它不知道您可能已设置的任何自定义远程存储库。 您可以在pom.xml文件中提供有关它的详细信息。
jd-repo JournalDev Maven Repo https://repo.journaldev.com/maven2/
翻译自:
简要说明下maven的作用
转载地址:http://tvqzd.baihongyu.com/