博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
简要说明下maven的作用_Maven资料库–简要指南
阅读量:2533 次
发布时间:2019-05-11

本文共 3852 字,大约阅读时间需要 12 分钟。

简要说明下maven的作用

什么是Maven资料库? (What is a Maven Repository?)

A maven repository is a central location that holds build artifacts and their metadata.

Maven存储库是存放构建工件及其元数据的中央位置。

Maven存储库有哪些不同类型? (What are the different types of Maven Repositories?)

There are two types of maven repositories.

Maven存储库有两种类型。

  1. Local Repository

    本地存储库
  2. Remote Repository

    远程仓库

本地存储库 (Local Repository)

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

远程仓库 (Remote Repository)

These are the repositories accessed with http or file protocol. They are on a remote system and holds artifacts from third-party libraries.

这些是使用httpfile协议访问的存储库。 它们位于远程系统上,并保存来自第三方库的工件。

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:

远程存储库可分为两种类型:

  1. Internal Remote Repository

    内部远程存储库
  2. Maven Central Repositoru

    Maven中央仓库

内部远程存储库 (Internal Remote Repository)

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中央存储库 (Maven Central Repository)

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存储库包含开源工件。 这些是每个人都使用的工件。 任何人都可以访问中央存储库并下载工件。 但是,您需要获得一个帐户才能将工件发布到中央存储库。

Maven依赖搜索算法 (Maven Dependencies Search Algorithm)

When a maven project is built, the required dependencies are searched in the following order.

构建Maven项目时,将按以下顺序搜索所需的依赖项。

  • local

    本地
  • central

    中央
  • remote, if available

    远程(如果有)
Maven Build Search Repository Order

Maven Build Search Repository Order

Maven构建搜索存储库顺序

If the dependencies are not found, the build fails with an unknown dependency error.

如果找不到依赖项,则构建将失败,并出现未知的依赖项错误。

将远程存储库添加到Maven pom.xml文件 (Adding Remote Repository to Maven pom.xml File)

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/

参考资料 (References)

翻译自:

简要说明下maven的作用

转载地址:http://tvqzd.baihongyu.com/

你可能感兴趣的文章
微信测试账户
查看>>
Android ListView上拉获取下一页
查看>>
算法练习题
查看>>
学习使用Django一 安装虚拟环境
查看>>
Hibernate视频学习笔记(8)Lazy策略
查看>>
CSS3 结构性伪类选择器(1)
查看>>
IOS 杂笔-14(被人遗忘的owner)
查看>>
自动测试用工具
查看>>
前端基础之BOM和DOM
查看>>
[T-ARA/筷子兄弟][Little Apple]
查看>>
编译Libgdiplus遇到的问题
查看>>
【NOIP 模拟赛】Evensgn 剪树枝 树形dp
查看>>
java学习笔记④MySql数据库--01/02 database table 数据的增删改
查看>>
两台电脑如何实现共享文件
查看>>
组合模式Composite
查看>>
程序员最想得到的十大证件,你最想得到哪个?
查看>>
我的第一篇CBBLOGS博客
查看>>
【MyBean调试笔记】接口的使用和清理
查看>>
07 js自定义函数
查看>>
jQueru中数据交换格式XML和JSON对比
查看>>