如何恢复损坏的 Eclipse 工作区?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/950476/
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-09-10 18:45:38  来源:igfitidea点击:

How to recover corrupted Eclipse workspace?

eclipserecoveryworkspacecorrupt

提问by Petteri Hietavirta

I just managed to corrupt contents of my Eclipse .metadata directory. Starting up with eclipse -clean did not work out. Deleting .metadata and then importing all projects, plugins and setting does not sound too interesting. I ended up moving .metadata/.plugins/org.eclipse.core.resources/ elsewhere and reimporting my projects only.

我只是设法破坏了我的 Eclipse .metadata 目录的内容。使用 eclipse -clean 启动没有成功。删除 .metadata 然后导入所有项目、插件和设置听起来不太有趣。我最终将 .metadata/.plugins/org.eclipse.core.resources/ 移动到其他地方并仅重新导入我的项目。

Are there any tools or best practices to recover workspace?

是否有任何工具或最佳实践来恢复工作区?

采纳答案by Christopher Thomas

I have some experience at recovering from eclipse when it becomes unstartable for whatever reason, could these blog entries help you?

当 Eclipse 由于某种原因变得无法启动时,我有一些从 Eclipse 中恢复的经验,这些博客条目对您有帮助吗?

http://blog.chris-alex-thomas.com/2009/08/26/eclipse-refuses-to-start-again/

http://blog.chris-alex-thomas.com/2009/08/26/eclipse-refuses-to-start-again/

also search for "cannot start eclipse" (I am a new user, I can only post a single hyperlink, so I have to just ask that you search for the second :( sorry)

还搜索“无法启动 eclipse”(我是新用户,我只能发布一个超链接,所以我只需要要求您搜索第二个:(抱歉)

perhaps those allow you to recover your workspace as well, I hope it helps.

也许这些也可以让您恢复您的工作区,我希望它有所帮助。

回答by Victor

When workspace is damaged and Eclipse cannot start, even using the -cleanoption, removing single file workspace/.metadata/.plugins/org.eclipse.core.resources/.snapmay help (source: comments to article http://letsgetdugg.com/2009/04/19/recovering-a-corrupt-eclipse-workspace/).

当工作区损坏且 Eclipse 无法启动时,即使使用该-clean选项,删除单个文件workspace/.metadata/.plugins/org.eclipse.core.resources/.snap也可能有所帮助(来源:文章评论http://letsgetdugg.com/2009/04/19/recovering-a-corrupt-eclipse-workspace/) .

Update: when Eclipse 4.X cannot start after crash, try to start with -clearPersistedStateoption; if it didn't help then remove file workspace/.metadata/.plugins/org.eclipse.e4.workbench/workbench.xmi(sources: http://www.eclipse.org/forums/index.php/m/1269045/http://www.eclipse.org/forums/index.php/t/522428/https://bugs.eclipse.org/bugs/show_bug.cgi?id=404873). Note: you'll lose configuration of your perspective/views/tabs.

更新:当 Eclipse 4.X 崩溃后无法启动时,尝试使用-clearPersistedStateoption启动;如果它没有帮助,则删除文件workspace/.metadata/.plugins/org.eclipse.e4.workbench/workbench.xmi(来源:http: //www.eclipse.org/forums/index.php/m/1269045/ http://www.eclipse.org/forums/index.php/t/ 522428/ https://bugs.eclipse.org/bugs/show_bug.cgi?id=404873)。注意:您将丢失透视图/视图/选项卡的配置。

Update: Subversive plugin may be responsible for unability to start Eclipse with corrupted metadata. If you have Subversive plugin installed, update it to latest build (at least 0.7.9.I20120210-1700) from update-site. Related bugs 372621and 370374were fixed by Subversive developers.

更新:Subversive 插件可能是由于元数据损坏而无法启动 Eclipse 的原因。如果您安装了 Subversive 插件,请从update-site 将其更新到最新版本(至少 0.7.9.I20120210-1700)。Subversive 开发人员修复了相关错误372621370374

回答by fastcodejava

You should be able to start your workspace after deleting the following file: .metadata.plugins\org.eclipse.e4.workbench\workbench.xmi as shown here:

您应该能够删除以下文件后,开始您的工作空间:.metadata.plugins \ org.eclipse.e4.workbench \ workbench.xmi如图所示在这里

回答by Ken

I haven't been able to avoid rebuilding workspace occasionally (one or twice over several years of using eclipse). Delete the .metedata and rebuild.

我无法避免偶尔重建工作区(在使用 eclipse 的几年中一两次)。删除 .metadata 并重建。

回答by miko?ak

One more solution that I've discovered by accident, and may help someone:

我偶然发现的另一种解决方案,可能对某人有所帮助:

  1. Back up the corrupted workspace.
  2. Move half of you projects to some temporary location.
  3. Start Eclipse, if it works, go to step 5.
  4. Move the half of projects you've removed back into the workspace, move out the other half. If you've already done that, keep removing/readding your projects in a binary searchmanner. Go to step 3.
  5. Exit Eclipse, move back all your projects, and start it again. You should see now that some of your projects are closed (and in the wrong working sets). Re-open your projects and move them to the correct working sets.
  1. 备份损坏的工作区。
  2. 将一半的项目移动到某个临时位置。
  3. 启动 Eclipse,如果正常,请转到第 5 步。
  4. 将您删除的一半项目移回工作区,移出另一半。如果您已经这样做了,请继续以二进制搜索方式删除/读取您的项目。转到步骤 3。
  5. 退出 Eclipse,移回所有项目,然后重新启动它。您现在应该看到您的一些项目已关闭(并且在错误的工作集中)。重新打开您的项目并将它们移动到正确的工作集。

In my case, it was a projectthat got corrupted, and not the entire workspace (attempting to import said project into a fresh workspace caused it to fail as well). So, I've started to search for the faulty project - instead, I got the result described above.

就我而言,这是一个已损坏的项目,而不是整个工作区(尝试将所述项目导入新的工作区也会导致它失败)。所以,我开始寻找有问题的项目——相反,我得到了上面描述的结果。

回答by Stijn de Witt

I have succesfully recovered my existingworkspace from a totally messed up situation (all kinds of core components giving NPE's and ClassCastExceptions and the like) by using this procedure:

通过使用以下过程,我已成功地从完全混乱的情况(各种核心组件提供 NPE 和 ClassCastExceptions 等)中恢复了我现有的工作区:

  • Open Eclipse
  • Close error dialog
  • Select first project in the workspace
  • Right-click -> Refresh
  • Close error dialog
  • Close Eclipse
  • Close error dialog
  • Repeat for all projects in the workspace
  • (if your projects are in CVS/SVN etc, synchronize them)
  • Clean and rebuild all projects
  • Fixed
  • 打开日食
  • 关闭错误对话框
  • 选择工作区中的第一个项目
  • 右键单击 -> 刷新
  • 关闭错误对话框
  • 关闭日食
  • 关闭错误对话框
  • 对工作区中的所有项目重复
  • (如果您的项目在 CVS/SVN 等中,请同步它们)
  • 清理并重建所有项目
  • 固定的

This whole procedure took me over half an hour for a big workspace, but it did fix it in the end.

对于一个大工作区,整个过程花了我半个多小时,但最终它确实修复了它。

回答by L. Hanke

This thread may be a bit older, but since this still is a problem nowadays, I thought I'd propose a new solution for backing up Eclipse.

这个线程可能有点旧,但由于现在这仍然是一个问题,我想我会提出一个新的解决方案来备份 Eclipse。

  • At http://profiles.yatta.deyou can download the Yatta Eclipse Launcher. You can use it to save your Eclipse and workspace setup.

  • After installation, the Launcher will discover your existing Eclipse installations and workspaces.

  • Click the Upload & Share button (the blue one) on the right of the entry you want to back up.

  • http://profiles.yatta.de,您可以下载 Yatta Eclipse Launcher。您可以使用它来保存 Eclipse 和工作区设置。

  • 安装后,启动器将发现您现有的 Eclipse 安装和工作区。

  • 单击要备份的条目右侧的上传和共享按钮(蓝色按钮)。

(You won't actually “share” your Eclipse or workspace with anyone. You'll just upload a setup file with your metadata that only you have access to yourself . You could share this later, but you can also just use it as a backup).

(您实际上不会与任何人“共享”您的 Eclipse 或工作区。您只需上传一个包含只有您自己才能访问的元数据的设置文件。您可以稍后共享,但您也可以将其用作备份)。

If you do that, you'll be able to re-setup your IDE really fast if you ever have a fragged workspace or Eclipse installation.

如果你这样做了,如果你曾经有一个破碎的工作区或 Eclipse 安装,你将能够非常快速地重新设置你的 IDE。

回答by syntagma

In my case only removing org.eclipse.e4.workbenchdirectory (under .metadata/.plugins) and restarting Eclipse solved the problem.

在我的情况下,只有删除org.eclipse.e4.workbench目录(在 下.metadata/.plugins)并重新启动 Eclipse才能解决问题。

回答by RC.

I know this sounds obvious, but if I'm writing code for a living I would be sure to do a full backup weekly, with corresponding incremental backups daily.

我知道这听起来很明显,但如果我以编写代码为生,我一定会每周进行一次完整备份,每天进行相应的增量备份。

Simple and easy recovery.

简单易行的恢复。

For a simple way to backup your eclipse directory and assuming your using Linux, you could use rsync.

对于备份 eclipse 目录并假设您使用 Linux 的简单方法,您可以使用 rsync。

rsync -ar <eclipse-dir> <backup-eclipse-dir>

rsync -ar <eclipse-dir> <backup-eclipse-dir>

You can put this in cron and have it backup your files automatically. It will only copy over the changed files to your backup-eclipse-dir on subsequent runs.

你可以把它放在 cron 中,让它自动备份你的文件。它只会在后续运行中将更改的文件复制到您的备份 eclipse 目录。

回答by user2367000

None of the above worked for me. But what actually worked was deleting all *.snap files from my workspace. This also preserves almost all settings including imported projects. Make sure to back up the workspace before trying it though!!!

以上都不适合我。但真正有效的是从我的工作区中删除所有 *.snap 文件。这也保留了几乎所有设置,包括导入的项目。在尝试之前一定要备份工作区!!!