简体   繁体   English

如何像 Eclipse 的 clean 一样清理 Intellij 想法中的项目缓存?

[英]How to clean project cache in Intellij idea like Eclipse's clean?

Sometimes the IDE makes some error because of the cache.有时 IDE 会因为缓存而出现一些错误。 In Eclipse, we can use clean to solve the problem.在Eclipse中,我们可以使用clean来解决这个问题。 But how can I do this in IntelliJ?但是我怎么能在 IntelliJ 中做到这一点呢?

Depending on the version you are running.取决于您运行的版本。 It is basically the same just go to基本上是一样的就去
File -> Invalidate caches , then restart Intellij File -> Invalidate caches ,然后重启 Intellij
or或者
File -> Invalidate caches / Restart文件-> 使缓存无效/重新启动

The main difference is that in older versions you had to manually restart as cache files are not removed until you restart.主要区别在于,在旧版本中,您必须手动重新启动,因为在重新启动之前不会删除缓存文件。 The newer versions will ask if you also want to restart.较新的版本会询问您是否还想重新启动。

旧版本 较新的版本

As seen here on this official Jetbrains help page 在此官方 Jetbrains 帮助页面上所见


You can also try delete caches manually in the system folder for your installed version.您还可以尝试手动删除system文件夹中已安装版本的缓存。 The location of this folder depends on your OS and version installed.此文件夹的位置取决于您的操作系统和安装的版本。

Windows Vista, 7, 8, 10 Windows Vista、7、8、10
<SYSTEM DRIVE>\\Users\\<USER ACCOUNT NAME>\\.<PRODUCT><VERSION>

Linux/Unix Linux/Unix
~/.<PRODUCT><VERSION>

Mac OS苹果系统
~/Library/Caches/<PRODUCT><VERSION>

Read this for more details on cache locations. 阅读本文以了解有关缓存位置的更多详细信息

Maybe not THE answer, but it's definitely AN answer.也许得不到答案,但它肯定是一个答案。

If nothing else is working for you, go the nuclear option: Close IDEA and delete the ".../.IntelliJIdea/system" directory using your local file system tools.如果没有其他方法适合您,请选择核心选项:关闭 IDEA 并使用本地文件系统工具删除“.../.IntelliJIdea/system”目录。

The .IntelliJIdea directory is usually found in your home directory. .IntelliJIdea 目录通常位于您的主目录中。 Your IDE configuration is in the ".../.IntelliJIdea/config" directory, so it should be fine.您的 IDE 配置位于“.../.IntelliJIdea/config”目录中,因此应该没问题。

Obviously, this is not the "IDEA" way to do it and would be completely unsupported by JetBrains.显然,这不是“IDEA”方式,JetBrains 完全不支持。 Also - I don't use Android Studio so I dunno if this will cause problems, but there you go.另外 - 我不使用 Android Studio,所以我不知道这是否会导致问题,但是你去了。

It's worked for me before when I've had problems getting IDEA to start and nothing else works to get me going.当我在启动 IDEA 时遇到问题并且没有其他任何方法可以让我前进时,它对我有用。 Maybe back up your entire .IntelliJIdea directory if you have a morbid fear of losing all your work >.<如果您害怕丢失所有工作,请备份整个 .IntelliJIdea 目录>.<

除了.Intellij*文件和使缓存无效之外,如果您真的想清除所有内容,那么还要删除 IntelliJ 还生成的.idea文件夹和*.iml每个项目文件...

Try this:试试这个:

Go into Settings (File > Settings or ctrl+alt+S).进入设置(文件 > 设置或 ctrl+alt+S)。 Under Project Settings, select the "Compiler" node.在项目设置下,选择“编译器”节点。 On the left, uncheck "Clear output directory on rebuild".在左侧,取消选中“重建时清除输出目录”。

Note that this is a per project setting.请注意,这是每个项目的设置。 If desired, change it in the project template settigs (Settings > Other Settings > Template Settings).如果需要,在项目模板设置中更改它(设置 > 其他设置 > 模板设置)。

1) File -> Invalide Caches (in IDE IDEA) 1) File -> Invalide Caches(在IDE IDEA中)

2) Manually, got to C:\\Users\\\\AppData\\Local\\JetBrains\\IntelliJ IDEA \\system\\caches and delete 2) 手动,到 C:\\Users\\\\AppData\\Local\\JetBrains\\IntelliJ IDEA\\system\\caches 并删除

JetBrains: https://intellij-support.jetbrains.com/hc/en-us/articles/206544519-Directories-used-by-the-IDE-to-store-settings-caches-plugins-and-logs JetBrains: https : //intellij-support.jetbrains.com/hc/en-us/articles/206544519-Directories-used-by-the-IDE-to-store-settings-caches-plugins-and-logs

Delete the "target" folder under the offending module.删除违规模块下的“目标”文件夹。 Then Build |然后构建 | Rebuild Project.重建项目。 Also make sure your clear the web browsers cache.还要确保清除网络浏览器缓存。

Sometimes the IDE makes some error because of the cache.有时,由于缓存,IDE会出错。 In Eclipse, we can use clean to solve the problem.在Eclipse中,我们可以使用clean来解决问题。 But how can I do this in IntelliJ?但是如何在IntelliJ中执行此操作?

另一个解决方案是 VCS -> Cleanup Project capture

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM