mvn清理缓存,清理Maven m2e .cache目录

My Maven installation (Windows 7 64-bit) has a .cache directory that is almost 3.5GB! It contains only a m2e directory. (I'm running Eclipse 4.3M7 with m2e.) Surely all the things inside aren't needed at present, and moreover I don't even know what this stuff is! I could find no Maven documentation of a .cache directory online.

So what are the .m2/repository/.cache and .m2/repository/.cache/m2e directories? Why do they have so much stuff from years ago? How do I dispose of all the stuff that's not needed anymore?

解决方案

In contrast to the other answers, make sure to keep .m2/*.xml (your settings) and .m2/repository (not strictly necessary to keep, but Maven will have to download half the Internet again).

Now, as for that .cache folder: if you open Eclipse, M2Eclipse will sometimes run a job akin to "Downloading repository indexes". These indexes allow you to quickly find an artifact using M2E's "Add dependency" wizard if you only know (part of) its artifact id. It needs to put the downloaded index files somewhere, and according to http://dev.eclipse.org/mhonarc/lists/m2e-users/msg02486.html the .cache folder is where they go:

Also note that m2e keeps at least three copies of each repository

index. The original .gz files downloaded from remote repositories. A

shared lucene instance used to optimize time spent processing gz

files. And per-workspace lucene indexes. The first two are stored

under local repository .cache/m2e directory, the last one is

per-workspace.

The Lucene stuff they're talking about are extra optimized search databases, this makes it faster for M2E to search a given artifact if you only enter a partial artifact id or group id.

m2e caches lucene index in two places. Per-workspace indexes are

stored under .metadata/.plugins/org.eclipse.m2e.core/nexus and there

is also global cache in ~/.m2/repository/.cache/m2e/${m2e.version}.

Try cleaning the caches and see if the problem goes away.

Keep in mind though that M2E will notice the missing folder the next time you open Eclipse, so be prepared to wait while it downloads all repository indexes again!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Maven 是一款使用广泛的项目构建工具,它通过提供一组简单易用的命令和配置方式,帮助开发者管理项目依赖、编译、打包等工作。其中,_remote.repositories 是一种特殊的文件,用于记录 Maven 项目的远程仓库信息。 _maven.repositories 文件和 _remote.repositories 文件都是以 "_" 开头的,用于指示 Maven 一些特殊操作时需要使用的文件。其中,_remote.repositories 是用于记录项目依赖的远程仓库信息的文件。每当我们在 Maven 项目中引入一个依赖时,Maven 会自动从远程仓库下载该依赖的 jar 包,并在 _remote.repositories 文件中记录这个依赖的远程仓库地址。 清除 _remote.repositories 文件可以通过以下步骤来完成: 1. 打开命令行终端,进入 Maven 项目的根目录。 2. 使用以下命令清除 _remote.repositories 文件: ``` mvn dependency:purge-local-repository ```` 这个命令会将所有本地的 Maven 仓库中已经下载的依赖文件删除,包括 _remote.repositories 文件。 3. 重新构建项目,使用以下命令清除 _remote.repositories 文件: ``` mvn clean install ``` 这个命令会执行项目清理操作,并重新生成可执行的项目文件,同时也会重新下载依赖并生成新的 _remote.repositories 文件。 总结来说,当我们需要清除 Maven 项目中的 _remote.repositories 文件时,可以使用 Maven 提供的命令 `dependency:purge-local-repository` 函数来删除本地 Maven 仓库中的所有依赖文件,并重新构建项目来生成新的 _remote.repositories 文件。这样就可以确保 _remote.repositories 文件中记录的是最新的远程仓库地址。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值