清除 Eclipse 工作区元数据

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

Clean out Eclipse workspace metadata

eclipsemetadataconfiguration-filesworkspaceeclipse-metadata

提问by Ted Hopp

I use multiple workspaces with Eclipse. I recently noticed that some of my workspaces have a lot of cruft in them from software packages that I installed and then later removed. As far as I can tell, the situation is that many packages write stuff (sometimes a lot of stuff) to the .metadata folder for every workspace I open while the package was installed. When I removed a package, it seems to clean out the .metadata folder for the workspace that I happen to have open at the time, but all the other workspaces are left with orphaned metadata. Sometimes this metadata causes problems—often, errors while opening the workspace and sometimes instability.

我在 Eclipse 中使用多个工作区。我最近注意到我的一些工作区中有很多来自我安装然后删除的软件包的残留物。据我所知,情况是许多包在安装包时为我打开的每个工作区将内容(有时是很多内容)写入 .metadata 文件夹。当我删除一个包时,它似乎清除了我当时打开的工作区的 .metadata 文件夹,但所有其他工作区都留下孤立的元数据。有时,此元数据会导致问题——通常是打开工作区时出错,有时甚至不稳定。

The only way I know to deal with this is to create a new workspace, import projects from the polluted workspace, reconstructing all my settings (a major pain) and then delete the old workspace. Is there an easier way to deal with this?

我知道处理这个问题的唯一方法是创建一个新的工作区,从受污染的工作区导入项目,重建我的所有设置(一个主要的痛苦),然后删除旧的工作区。有没有更简单的方法来处理这个问题?

采纳答案by Bananeweizen

There is no easy way to remove the "outdated" stuff from an existing workspace. Using the "clean" parameter will not really help, as many of the files you refer to are "free form data", only known to the plugins that are no longer available.

没有简单的方法可以从现有工作区中删除“过时”的东西。使用“clean”参数并没有真正的帮助,因为您引用的许多文件都是“自由格式数据”,只有不再可用的插件才知道。

Your best bet is to optimize the re-import, where I would like to point out the following:

最好的办法是优化重新导入,我想指出以下几点:

  • When creating a new workspace, you can already choose to have some settings being copied from the current to the new workspace.
  • You can export the preferences of the current workspace (using the Exportmenu) and re-import them in the new workspace.
  • There are lots of recommendations on the Internet to just copy the ${old_workspace}/.metadata/.plugins/org.eclipse.core.runtime/.settingsfolder from the old to the new workspace. This is surely the fastest way, but it may lead to weird behaviour, because some of your plugins may depend on these settings andon some of the mentioned "free form data" stored elsewhere. (There are even people symlinking these folders over multiple workspaces, but this really requires to use the same plugins on all workspaces.)
  • You may want to consider using more project specific settings than workspace preferences in the future. So for instance all the Java compiler settings can either be set on the workspace level or on the project level. If set on the project level, you can put them under version control and are independent of the workspace.
  • 创建新工作区时,您已经可以选择将某些设置从当前工作区复制到新工作区。
  • 您可以导出当前工作区的首选项(使用“导出”菜单)并在新工作区中重新导入它们。
  • 互联网上有很多建议,只需将${old_workspace}/.metadata/.plugins/org.eclipse.core.runtime/.settings文件夹从旧工作区复制到新工作区即可。这肯定是最快的方法,但它可能会导致奇怪的行为,因为您的某些插件可能依赖于这些设置以及存储在其他地方的一些提到的“自由格式数据”。(甚至有人在多个工作区上对这些文件夹进行符号链接,但这确实需要在所有工作区上使用相同的插件。)
  • 将来您可能需要考虑使用比工作区首选项更多的项目特定设置。例如,所有 Java 编译器设置都可以在工作区级别或项目级别进行设置。如果在项目级别设置,您可以将它们置于版本控制之下并且独立于工作区。

回答by Ashutosh Jindal

One of the things that you might want to try out is starting eclipse with the -cleanoption. If you have chosen to have eclipse use the same workspace every time then there is nothing else you need to do after that. With that option in place the workspace should be cleaned out.

您可能想要尝试的一件事是使用该-clean选项启动 eclipse 。如果您选择让 Eclipse 每次都使用相同的工作区,那么此后您无需执行任何其他操作。使用该选项后,应清理工作区。

However, if you don't have a default workspace chosen, when opening up eclipse you will be prompted to choose the workspace. At this point, choose the workspace you want cleaned up.

但是,如果您没有选择默认工作区,则在打开 eclipse 时会提示您选择工作区。此时,选择要清理的工作区。

See "How to run eclipse in clean mode"and "Keeping Eclipse running clean"for more details.

有关更多详细信息,请参阅“如何在干净模式下运行 eclipse”“保持 Eclipse 运行干净”

回答by kandysingh

In my case eclipse is not showing parent class function on $this, so I perform below mention points and it starts works:-

在我的情况下,eclipse 没有在 $this 上显示父类函数,所以我执行以下提到的点并开始工作:-

I go to my /var/www/ folder and check for .metadata folder (Here check the .log file and it shows) Resource is out of sync with the file system: 1. Go to Eclipse --> Project --> Clean 2. Windows -- preferences --> General --> Workspace --> And set it to "Refresh Automatically"

我转到我的 /var/www/ 文件夹并检查 .metadata 文件夹(此处检查 .log 文件并显示)资源与文件系统不同步: 1. 转到 Eclipse --> Project --> Clean 2. Windows -- 首选项 --> 常规 --> 工作区 --> 并设置为“自动刷新”

After that boom - things gets start working :)

在那次繁荣之后 - 事情开始运作:)

If you want to load variables from other files too then ado this :- Eclipse-->Windows-->Preferences-->Php-->Editor-->Content Assist --> and check "show variable from other files"

如果您也想从其他文件加载变量,那么请执行以下操作:- Eclipse-->Windows-->Preferences-->Php-->Editor-->Content Assist --> 并选中“显示来自其他文件的变量”

Then it will show element , variables and other functions also.

然后它也会显示元素、变量和其他函数。

回答by Lonzak

The only way I know to deal with this is to create a new workspace, import projects from the polluted workspace, reconstructing all my settings (a major pain) and then delete the old workspace. Is there an easier way to deal with this?

我知道处理这个问题的唯一方法是创建一个新的工作区,从受污染的工作区导入项目,重建我的所有设置(一个主要的痛苦),然后删除旧的工作区。有没有更简单的方法来处理这个问题?

For synchronizing or restoring all our settings we use Workspace Mechanic. Once all the settings are recorded its one click and all settings are restored... You can also setup a server which provides those settings for all users.

为了同步或恢复我们的所有设置,我们使用Workspace Mechanic。记录所有设置后,只需单击一下即可恢复所有设置...您还可以设置一个服务器,为所有用户提供这些设置。

回答by Ansgar Radermacher

In some cases, I could prevent Eclipse from crashing during startup by deleting a .snap file in your workspace meta-data (.metadata/.plugins/org.eclipse.core.resources/.snap).

在某些情况下,我可以通过删除工作区元数据 (.metadata/.plugins/org.eclipse.core.resources/.snap) 中的 .snap 文件来防止 Eclipse 在启动期间崩溃。

See also https://bugs.eclipse.org/bugs/show_bug.cgi?id=149121(the bug has been closed, but happened to me recently)

另请参阅https://bugs.eclipse.org/bugs/show_bug.cgi?id=149121(该错误已关闭,但最近发生在我身上)