在 Maven 中定义存储库 [英] Defining Repository in Maven

查看:55
本文介绍了在 Maven 中定义存储库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚在 maven 中开始了几个项目,很想知道定义存储库的最佳方法是什么?

I have just started with couple of projects in maven , keen to know what is the best way to define repository ?

到目前为止我所理解的是以下两种方式:1. 本地2. 远程当我们使用本地存储库时,我们指的是我们的安装,否则它将首先在本地目录(远程缓存)中检查依赖

What I understood so far is the following two ways : 1. Local 2. Remote When we are using local repository we are refering to our installation or it will check the depency first in a local directory(cache of remote)

虽然远程存储库设置了第三方来下载他们的工件.(例如某处file://someurlhttp://someurl)

While remote repository set up a third party to download their artifacts.(e.g somewhere file://someurl or http://someurl)

如果我错了,请纠正我,我想知道定义存储库的最佳方法是什么,请记住,如果有人在低带宽连接上使用项目,性能不应该受到影响.

Please correct me if I am wrong , and I want to know what is the best way to define repositories keeping in mind if some one is using project on a low bandwidth connection the performance should not hamper .

推荐答案

最好的方法是保持默认行为:位于 /.m2/repository 的本地存储库.

The best way is to keep the default behavior: a local repository located in <USER_HOME>/.m2/repository.

您将运行的第一个 (s) mvn 命令会很慢,因为此存储库需要由大量库(maven 插件以及依赖项中的库和框架)填充.

The first(s) mvn command you will run will be slow because this repository need to be populated by a lot of libraries (maven plugins and libraries and frameworks in your dependencies).

当您运行 mvn install 时,此本地存储库将安装您的工件.

This local repository is where your artifacts will be installed when you run mvn install.

如果您需要与同事共享工件,您可以:

If you need to share artifacts with colleagues, either you :

  • 通过 SCM 完成(即,您的同事必须检查您的代码并运行 mvn install,以便您的库在他们的本地存储库中可用)
  • 通过存储库管理器(artifactory 或 nexus)完成(然后在 settings.xml 中使用适当的配置运行 mvn deploy 以通过存储库管理器以二进制形式让您的同事使用您的工件).
  • do it through SCM (i.e. your colleagues will have to checkout your code and run mvn install so that your libraries will be available in their local repository)
  • do it through a repository manager (artifactory or nexus) (then run mvn deploy with proper configuration in your settings.xml to make your artifacts available for your colleagues in a binary form via the repository manager).

建议您在安装存储库管理器之前先熟悉 maven.

I suggest you to first getting familiar with maven before installing a repository manager.

这篇关于在 Maven 中定义存储库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆