如何恢复损坏的 Eclipse 工作区?
我刚刚设法损坏了 Eclipse .metadata 目录的内容。 使用 eclipse -clean 启动没有成功。 删除 .metadata 然后导入所有项目、插件和设置听起来不太有趣。 我最终将 .metadata/.plugins/org.eclipse.core.resources/ 移到其他地方并仅重新导入我的项目。
是否有任何工具或最佳实践来恢复工作区?
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.
Are there any tools or best practices to recover workspace?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(15)
当工作区损坏并且 Eclipse 无法启动时,即使使用 -clean 选项,删除单个文件workspace/.metadata/.plugins/org.eclipse.core.resources/.snap 可能会有所帮助(来源:对文章的评论 https://web.archive.org/web/20200517003712/https://letsgetdugg.com/2009/04/19/recovering-a-corrupt-eclipse-workspace/)。
更新:当Eclipse 4.X崩溃后无法启动时,尝试使用
-clearPersistedState
选项启动; 如果没有帮助,则删除文件workspace/.metadata/.plugins/org.eclipse.e4.workbench/workbench.xmi
(来源:https://www.eclipse.org/forums/index.php/m/1269045/ https://www.eclipse.org/forums/index.php/t/522428/ https://bugs.eclipse.org/bugs/show_bug.cgi?id=404873 )。 注意:您将丢失透视图/视图/选项卡的配置。更新:Subversive 插件可能会导致元数据损坏时无法启动 Eclipse。 如果您安装了 Subversive 插件,请从 更新站点。 相关错误 372621 和 370374 已由 Subversive 开发人员修复。
When workspace is damaged and Eclipse cannot start, even using the
-clean
option, removing single fileworkspace/.metadata/.plugins/org.eclipse.core.resources/.snap
may help (source: comments to article https://web.archive.org/web/20200517003712/https://letsgetdugg.com/2009/04/19/recovering-a-corrupt-eclipse-workspace/).Update: when Eclipse 4.X cannot start after crash, try to start with
-clearPersistedState
option; if it didn't help then remove fileworkspace/.metadata/.plugins/org.eclipse.e4.workbench/workbench.xmi
(sources: https://www.eclipse.org/forums/index.php/m/1269045/ https://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.Update: Subversive plugin may be responsible for inability 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 372621 and 370374 were fixed by Subversive developers.
删除以下文件后,您应该能够启动工作区:
.metadata.plugins\org.eclipse.e4.workbench\workbench.xmi 如此处所示:
You should be able to start your workspace after deleting the following file:
.metadata.plugins\org.eclipse.e4.workbench\workbench.xmi as shown here :
我有一些从 Eclipse 恢复的经验,当它由于某种原因变得无法启动时,这些博客文章可以帮助你吗?
链接(已存档)
还搜索“无法启动 eclipse”(我是新用户,我只能发布一个超链接,所以我必须要求您搜索第二个:(抱歉)
也许这些也可以让您恢复工作空间,我希望它有帮助。
I have some experience at recovering from eclipse when it becomes unstartable for whatever reason, could these blog entries help you?
link (archived)
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)
perhaps those allow you to recover your workspace as well, I hope it helps.
我无法避免偶尔重建工作区(使用 Eclipse 的几年中有一两次)。 删除 .metedata 并重建。
I haven't been able to avoid rebuilding workspace occasionally (one or twice over several years of using eclipse). Delete the .metedata and rebuild.
我偶然发现的另一种解决方案可能会对某人有所帮助:
就我而言,这是一个项目被损坏,而不是整个工作区(尝试将所述项目导入到新的工作区也会导致它失败)。 因此,我开始寻找有问题的项目 - 相反,我得到了上述结果。
One more solution that I've discovered by accident, and may help someone:
In my case, it was a project that 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.
我已经使用以下过程成功地从完全混乱的情况(各种核心组件提供 NPE 和 ClassCastExceptions 等)中恢复了我的现有工作区:
对于一个大工作区,整个过程花了我半个多小时,但最终确实解决了这个问题。
I have succesfully recovered my existing workspace from a totally messed up situation (all kinds of core components giving NPE's and ClassCastExceptions and the like) by using this procedure:
This whole procedure took me over half an hour for a big workspace, but it did fix it in the end.
这个线程可能有点旧,但由于现在这仍然是一个问题,我想我会提出一个新的解决方案来备份 Eclipse。
在 http://profiles.yatta.de 您可以下载 Yatta Eclipse Launcher。 您可以使用它来保存 Eclipse 和工作区设置。
安装后,启动器将发现您现有的 Eclipse 安装和工作区。
单击上传并单击 您要备份的条目右侧的“共享”按钮(蓝色按钮)。
(您实际上不会与任何人“共享”您的 Eclipse 或工作区。您只需上传一个包含元数据的安装文件,只有您自己可以访问该文件。您可以稍后共享该文件,但也可以将其用作备份)。
如果您这样做,如果您的工作区或 Eclipse 安装有碎片,您将能够非常快速地重新设置您的 IDE。
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.
At http://profiles.yatta.de you 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.
(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).
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.
在我的例子中,仅删除 org.eclipse.e4.workbench 目录(在 .metadata/.plugins 下)并重新启动 Eclipse 就解决了问题。
In my case only removing
org.eclipse.e4.workbench
directory (under.metadata/.plugins
) and restarting Eclipse solved the problem.以上都不适合我。 但实际有效的是从我的工作区中删除所有 *.snap 文件。 这还保留了几乎所有设置,包括导入的项目。 不过,在尝试之前请务必备份工作区!
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!!!
删除下面的文件帮助我解决了 eclipse 启动问题。 Perforce 插件一直困扰着我,尤其是当我的机器重新启动时,下次 Eclipse 尝试恢复工作区并崩溃时。
workspace/.metadata/.plugins/org.eclipse.core.resources/.snap
供您参考,我收到的错误:
org.eclipse.core.runtime.CoreException:插件 com.perforce.team.ui 无法加载类 com.perforce.team.ui.UITeamProvider。
deleting below file helped me solve my eclipse start up issue. Perforce plugin has always troubled me especially when my machine reboots, next time eclipse tries to recover workspace and craps out.
workspace/.metadata/.plugins/org.eclipse.core.resources/.snap
For your reference, Error I was getting:
org.eclipse.core.runtime.CoreException: Plug-in com.perforce.team.ui was unable to load class com.perforce.team.ui.UITeamProvider.
就我而言,损坏的不是工作区,而是 Eclipse 本身,与错误对话框所示的不同。 重新安装 Eclipse 并将其指向工作区后,问题得到解决。 可能有用于修复损坏的工作区的工具,但重新安装 Eclipse 可能值得一试。
In my case, it was not the workspace that was broken, but Eclipse itself, unlike what the error dialog indicated. After reinstalling Eclipse and pointing it to the workspace, the issue was fixed. There might be tools for repairing broken workspaces, but reinstalling Eclipse might be worth a go.
我知道这听起来很明显,但如果我以编写代码为生,我一定会每周进行一次完整备份,每天进行相应的增量备份。
简单易行的恢复。
对于备份 eclipse 目录的简单方法,假设您使用 Linux,您可以使用 rsync。
rsync -ar; <备份-eclipse-dir>
您可以将其放入 cron 中并让它自动备份您的文件。 它只会在后续运行时将更改的文件复制到您的 backup-eclipse-dir 中。
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.
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.
删除workspace/.metadata/.plugins/org.eclipse.wst.jsdt.core/中扩展名为.dat的文件,然后关闭e并打开eclipse,也许你无法关闭eclipse,强制它,如果你是的话,使用pkill -f eclipse在 Linux 或类似系统上。
该解决方案避免导入所有现有项目。
Remove a file with .dat extension in workspace/.metadata/.plugins/org.eclipse.wst.jsdt.core/ and then close eand open eclipse, maybe you cannot close eclipse, force it, with pkill -f eclipse if you are on linux or similar.
This solution avoid to import all of existents projects.
我也遇到过这样的问题,我的工作区已损坏,无法再执行所有重要的操作。
由于某种原因,我的一个项目中的资源已损坏。 它没有出现在包树中,但它确实在 Eclipse 的错误日志中显示为
检查每个项目后(因为错误没有指向一个),我确实在构建路径之一中找到了此资源(在“配置构建路径”菜单中,它确实显示了错误图标!)并将其删除。
请参阅 Eclipse (Kepler) 工作区行为怪异(类型层次结构,如果您遇到类似的情况,搜索参考文献不起作用),以获取对我的问题的更广泛的描述。
发布此供将来的开发人员参考。
I also experienced an issue like this, my workspace was corrupted and didn't do all the important things anymore.
For some reason, I had a corrupt resource on one of my projects. It didn't show up in the package tree, but it did show in the error log in Eclipse as
After checking every project (because the error didn't point to one), I indeed found this resource in one of the build paths (in Configure Build Path menu it did show an error icon!) and deleted it.
See Eclipse (Kepler) Workspace acting weird (type hierarchy, searching for references not working) for a wider description of my issue if you're experiencing something similar.
Posted this for future developers to reference.
如果工作区不是那么大,您可以备份到保管箱作为私人锁定文件夹。
If the workspace is not that big you could backup to say dropbox as a private locked folder.