Java 将完整的 maven 远程存储库下载到本地存储库?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2439891/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-13 07:40:26  来源:igfitidea点击:

Downloading complete maven remote repository to Local repository?

javamaven-2mavenmaven-plugin

提问by srinannapa

Is there any to get the entire remote repository, say from http://repo1.maven.org/maven2/, to my local repository (to %USERPROFILE%)?

是否可以将整个远程存储库(例如从http://repo1.maven.org/maven2/)获取到我的本地存储库(到%USERPROFILE%)?

采纳答案by Pascal Thivent

From http://maven.apache.org/community.html:

来自http://maven.apache.org/community.html

Being a Good Maven Citizen

The concept of a public repository built into the core architecture of Maven makes it necessarily community-centric. There are a few simple things that Maven users may do to help keep that community thriving.

Be a Kind Public Repository User

The best thing that a user can do is to set up their own remote repository mirror containing the projects needed. There are several tools to make this simpler, such as Nexusor Archiva. This reduces strain on the Maven central repository, and allows new users to get acquainted with Maven easier and quicker. This is especially important for power-users and corporations. The incentive behind this is, controlling your own servers can give you desired level of security and more control over uptime, resulting in a better experience for your users. With that said, keep the following sentiment in mind:

DO NOT wget THE ENTIRE REPOSITORY!

Please take only the jars you need. We understand this is may entail more work, but grabbing all 9+ Gigs of binaries really kills our servers.

Host a Mirror

As an extention to the previous statement, if you have access to a large data repository with lots of bandwidth, please consider becomming a mirror for the Maven central repository.

As you can imagine, thousands of users downloading can put quite a strain on one server. If you wish to be a mirror, please file a request in the Maven Project AdministrationJIRA project.

Host a Public Repository

If you have any projects that you wish others to use, host them on your own public repository. That way, your users can simply add your repository to their own project repo list, and viola! Maven can keep you and your users in synch, growing your user-base due simply to its new-found ease of use.

做一个好的Maven公民

内置于 Maven 核心架构中的公共存储库的概念使其必然以社区为中心。Maven 用户可以做一些简单的事情来帮助保持社区的繁荣。

做一个善良的公共存储库用户

用户可以做的最好的事情是设置他们自己的包含所需项目的远程存储库镜像。有几种工具可以使这更简单,例如NexusArchiva。这减少了 Maven 中央存储库的压力,并允许新用户更容易、更快地熟悉 Maven。这对于高级用户和公司尤其重要。这背后的动机是,控制您自己的服务器可以为您提供所需的安全级别和对正常运行时间的更多控制,从而为您的用户带来更好的体验。话虽如此,请记住以下情绪:

不要获取整个存储库!

请只拿你需要的罐子。我们知道这可能需要做更多的工作,但是获取所有 9+ Gig 的二进制文件确实会杀死我们的服务器。

主持镜子

作为前文的延伸,如果您可以访问具有大量带宽的大型数据存储库,请考虑成为 Maven 中央存储库的镜像。

可以想象,成千上万的用户下载会给一台服务器带来相当大的压力。如果您希望成为镜像,请在Maven 项目管理JIRA 项目中提出请求 。

托管公共存储库

如果您希望其他人使用任何项目,请将它们托管在您自己的公共存储库中。这样,您的用户可以简单地将您的存储库添加到他们自己的项目存储库列表中,并且中提琴!Maven 可以让您和您的用户保持同步,仅由于其新发现的易用性而扩大您的用户群。

Maybe if you explain why you'd like to get the whole central repo in %USERPROFILE%I could provide a better answer (if you you need to go offline, there are smarter solutions than getting 9+ gigs of artifacts). But for now, I don't get the point.

也许如果你解释为什么你想要获得整个中央回购%USERPROFILE%我可以提供一个更好的答案(如果你需要离线,有比获得 9 多个工件更聪明的解决方案)。但现在,我不明白这一点。

回答by brabster

I'm not sure how you would do that using Maven. It might be useful to explain what you are trying to achieve - at a guess you want a local cache?

我不确定您将如何使用 Maven 做到这一点。解释您要实现的目标可能很有用 - 猜测您想要本地缓存?

What you might be looking for really is a local repository manager like Sonatype's Nexus. These repository managers provide a local cache for remote repositories, as well as providing somewhere for you to put your code.

您可能真正需要的是像 Sonatype 的Nexus这样的本地存储库管理器。这些存储库管理器为远程存储库提供本地缓存,并为您提供放置代码的地方。

回答by akostadinov

I just had to mirror a private product repo to make available on another machine. lftp worked just fine:

我只需要镜像一个私有产品仓库就可以在另一台机器上使用。lftp 工作得很好:

$ lftp http://my.repo.example.com/product/maven
mirror --no-empty-dirs --parallel=3 . my-local-repo

回答by PaulG

"wget -m http://site.to.mirror.com" should do it

“wget -m http://site.to.mirror.com”应该这样做

-m stands for "mirror".

-m 代表“镜子”。