Maven:消除本地存储库中除最新版本之外的所有库 [英] Maven: eliminate all but latest version of library in local repo
问题描述
我在我的项目中使用了一个库,我在开发过程中经历了它的许多版本,所以我的本地 Maven 存储库包含该库的许多旧版本.
There's a library that I am using in my project and I have gone through many versions of it during development, so my local Maven repository contains many of the older versions of this library.
我怀疑冲突可能会导致我一直遇到的一些奇怪的问题,所以我想从我的本地 Maven 存储库中删除除此库的最新版本之外的所有内容.
I suspect conflicts might be causing some strange issues I have been having, so I want to eliminate all but the latest version of this library from my local maven repository.
我该怎么做?
如果有什么不同,我目前正在使用该库的 SNAPSHOT 版本(根据其开发人员的推荐).
If it makes any difference, I am currently using a SNAPSHOT version of this library (as recommended by its developers).
PS:删除整个存储库不是一个非常实用的选择,因为存储库目前超过 1.2G,而且我的连接速度很慢,而且有上限.
PS: deleting the entire repository is not a very practical option, as the repo is currently over 1.2G and I have a slow, capped connection.
推荐答案
如果您知道依赖坐标,您可以从本地目录中手动删除它们.例如,如果这是您的依赖项:
If you know the dependency coordinates you can delete them manually from the local directory. For example if this was your dependency:
<dependency>
<groupId>org.glassfish.jersey</groupId>
<artifactId>jersey-bom</artifactId>
<version>2.9</version>
</dependency>
在 Linux 上你可以运行:
On Linux you could run:
rm -rf ~/.m2/repository/org/glassfish/jersey/jersey-bom/
在 Windows 上,您可以使用资源管理器将其删除或运行:
On Windows you can use explorer to delete it or run:
rd /S /Q C:\Users\%username%\.m2\repository\org\glassfish\jersey\jersey-bom\
这篇关于Maven:消除本地存储库中除最新版本之外的所有库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!