使用公共Maven存储库而不是本地库的优点 [英] Advantages of using public maven repository for libraries instead of local

查看:105
本文介绍了使用公共Maven存储库而不是本地库的优点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

与在本地存储库相比,使用Maven的公共存储库有什么优势?

在使用公共存储库时,我看到以下缺点:

  • 如果出于某种原因更新了某些库,考虑到我使用了必定会发生的数百个库,我的应用程序可能会崩溃.
  • 如果指定了特定的库版本以避免更新的版本破坏应用程序,则该特定版本可能不再可用.
  • 存储库可能始终会遇到网络问题或完全阻止软件开发的类似错误,通过git共享所有必需jar的本地lib文件夹会更可靠.

为了避免使用公共仓库,我正在关注此建议,但是有人也建议

"运行类似Nexus的东西,您自己的Maven存储库,您可以上载第三方专有的jar文件,还可以代理其他公共存储库,以保存在bandwith上?

那真的总结了我的疑问:为什么要为简单地与几个开发人员共享库文件而经历所有的痛苦呢?

解决方案

  • 如果出于某种原因更新了一些库,考虑到我使用了必定会发生的数百个库,我的应用程序可能会崩溃.

不.我知道墨菲定律指出任何可能发生的事情都会发生.但是在Maven Central中发布的库应该是稳定的.如果库已更新,它将具有新版本,因此不会发生冲突.没有一个理智的图书馆维护者会反对.

  • 如果指定了特定的库版本以避免更新的版本破坏应用程序,则该特定版本可能不再可用.

不. 您无法从Maven Central中删除工件.所以这是不可能的.

  • 存储库可能始终会遇到网络问题或完全阻止软件开发的类似错误,通过git共享所有必需jar的本地lib文件夹会更可靠.

虽然如此,但Maven保留了本地存储库中所有工件的缓存.只需下载一次即可.


使用内部存储库管理器的优点超出了缓存Maven Central的范围.它为所有依赖项(无论这些依赖项是否为公共)提供了一个中心入口点.它还可以托管内部库和私有库(例如Oracle JDBC).而且,对Maven项目而言,使用它是透明的:依赖项的声明方式完全相同,无论它是公共构件还是内部构件.

What are the advantages of using Maven's public repository vs storing your libraries locally?

I see the following disadvantages in using public repository:

  • If for some reason some library is updated my application will probably crash, considering I use hundreds of libraries that's bound to happen sometime.
  • If a specific library version is specified to avoid newer versions to break the application, that specific version might not be available anymore.
  • The repositories might always be subject to network problems or similar error blocking development of the software completely, a local lib folder with all the required jars shared through git is more robust.

In order to avoid using a public repo I'm following this advice, someone however also suggested

"run something like Nexus, your own maven repo that you can upload 3rd party proprietary jar files, and also proxy other public repositories, to save on bandwith?".

That really summarizes my doubts: why go through all that pain for simply sharing library files to a couple of developers?

解决方案

  • If for some reason some library is updated my application will probably crash, considering I use hundreds of libraries that's bound to happen sometime.

No. I know Murphy's law states that anything that can happen will happen. But libraries published in Maven Central are supposed to be stable. If a library is updated, it will be with a new version so there are no conflicts. No sane maintainer of a library would go against that.

  • If a specific library version is specified to avoid newer versions to break the application, that specific version might not be available anymore.

No. You can't remove an artifact from Maven Central. So this is not possible.

  • The repositories might always be subject to network problems or similar error blocking development of the software completely, a local lib folder with all the required jars shared through git is more robust.

While that is true, Maven keeps a cache of all artifacts inside your local repository. It just needs to download them once.


The advantage of using an internal repository manager goes beyond the scope of caching Maven Central. It allows a central entry point for all dependencies, whether or not those dependencies are public. It can also host internal library and private libraries (like Oracle JDBC). Also, using it is transparent for Maven projects: dependencies are declared exactly the same way, whether it is a public artifact or a in-house one.

这篇关于使用公共Maven存储库而不是本地库的优点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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