How to recover corrupted Eclipse workspace?

后端 未结 15 941
醉酒成梦
醉酒成梦 2020-12-07 16:43

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, p

相关标签:
15条回答
  • 2020-12-07 17:08

    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.

    0 讨论(0)
  • 2020-12-07 17:10

    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

    Error while creating a link for external folder X:\somefolder

    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.

    0 讨论(0)
  • 2020-12-07 17:13

    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:

    • 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

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

    0 讨论(0)
  • 2020-12-07 17:14

    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.

    0 讨论(0)
  • 2020-12-07 17:15

    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 search manner. 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.

    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.

    0 讨论(0)
  • 2020-12-07 17:17

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

    0 讨论(0)
提交回复
热议问题