163

Eclipse(带有 PyDev 的 3.4.2)处理不同步资源(已在 IDE 之外编辑的文件)与我使用过的其他 IDE 不同,在这些 IDE 中,只有打开编辑器的资源才被认为是不同步的. 在 Eclipse 中,任何资源都可能不同步。

这意味着当我在 Eclipse 之外更改任何文件后执行搜索时,我会收到一个错误对话框,告诉我文件不同步,即使它们没有打开的编辑器也是如此。据我所知,没有全局刷新命令,所以我不得不在错误对话框中读取项目名称(我有几个项目),并对每个项目进行右键单击 + 刷新。

我已经检查了 中的Refresh Automatically设置Settings > General > Workspace,但这没有效果。有没有办法让 Eclipse 总是从磁盘加载非活动资源?

4

13 回答 13

201

This issue will be fixed in Eclipse 3.7 (Indigo). While "Refresh Automatically" does eventually bring resources back into sync, the refresh hook only exists for Windows, so on Linux and Mac OS it has to poll the filesystem periodically.

From 3.7 there's a new preference Settings > General > Workspace > Refresh On Access (aka Lightweight Refresh). This preference causes Eclipse to automatically refresh resources when it discovers that they're 'out-of-sync'. When opening, reading or searching files, it'll prevent out-of-sync errors from occurring.

See also: https://bugs.eclipse.org/303517

于 2011-05-18T18:19:19.443 回答
29

我认为如果您在项目资源管理器中单击项目节点并按 F5 或右键单击并选择刷新,该项目的所有资源都将被刷新。此外,如果您 CTRL+单击多个项目,您应该能够同时刷新多个项目。

单击项目,按 CTRL+A 选择所有内容,按 F5 即可完成您需要的操作 - 刷新所有内容。

当我有机会时,我将不得不对此进行测试,但我相信这就是我过去克服类似问题的方式。


我注意到这个答案经常被否决。我想指出,这个问题指的是 Eclipse 的特定版本:3.4.2。正如James Blackburn 的回答中提到的,在Eclipse 的 3.7 Indigo 版本之前,实际上没有自动刷新不同步资源的方法。此答案中描述的方法是在 3.4.2 版本(以及 3.7 Indigo 之前的任何其他版本)中实现此目的的唯一方法。

于 2009-07-31T13:48:57.760 回答
24

Out of synchronization problem is common in eclipse IDE so you have to check this option windows -> preference -> Workspace -> refresh using native hooks or polling.

于 2015-11-14T07:25:41.230 回答
6

Eclipse Helios possesses a built in refresh feature at Preferences > General > Workspace. It's in the same spot where you disable automatic builds. Select refresh automatically. A plugin with the same functionality is Andrei Loskutov's Filesync Plugin. The update site address is: http://andrei.gmxhome.de/eclipse/. During installation, select Eclipse 3.5-3.7 plugins > FileSync.

于 2011-04-02T12:33:03.563 回答
5

Given that Java 7 has an api for filesystem hooks, one would think that refresh could be handled better in Eclipse.

Edit: Actually, there is a plugin that uses this mechanism: https://github.com/psxpaul/EclipseJava7Refresher

于 2013-04-24T05:36:24.043 回答
4

有一个全局刷新 - 在包资源管理器中没有选择任何(或所有内容)并按 F5(或右键单击空白区域并选择刷新)。当然,如果您有大型项目,这可能需要相当长的时间。

于 2009-07-31T13:52:16.150 回答
4

The global refresh actually exists in plain Eclipse without any plugins and without selecting every project in your workspace.

Basically you need to deselect everything in your project explorer and hit F5. To do that Ctrl+click the selected resource in the project explorer and hit F5.

于 2012-08-10T11:44:22.883 回答
3

A global refresh is really missing in Eclipse. The above procedure with selecting all projects and then running refresh (e.g. F5) does not work if you have closed projects included in your selection. This means, if you have 1/2 of your many projects closed as I do, you find yourself manually Ctrl-clicking through your dozens of projects. This is quite painful. I wish Eclipse would simply ignore closed projects.

于 2011-07-08T13:13:20.347 回答
2

也许您应该在 eclipse 站点上添加一个功能请求:

https://bugs.eclipse.org/bugs/

I think it would be a great idea to add a preference for automatically refreshing out of date resources.

于 2009-08-01T03:39:55.917 回答
2

Yes, Refresh on Access is long overdue ... those answers to this and similar enquires usually suggested enabling the global auto-refresh, which could take an age for large remote projects. In fact there are those who would say that Refresh on Access should have been the original (< 3.x) default behaviour ...

于 2011-07-01T11:16:02.660 回答
2

I managed to solve this by creating a new "external tool" run config that executes a blank batch file. In the run config, you can have it refresh the workspace when complete. Then I created a macro using Practically Macro that 1) executes the last external tool run config (refreshing the workspace), then 2) executes the last debug run config (running my app). If you uncheck "Allocate console" then the completed external tool entry won't show up in the debug window.

于 2011-08-23T20:50:56.523 回答
1

Even if the solutions proposed by others perso are indeed correct, you have a "Refresh All" plugin for Eclipse. Simply add the Update page to your Eclipse list of update sites to install it in your IDE.

于 2010-02-19T14:30:49.347 回答
0

For Starting up there is an option to automatically refresh files in

Window -> Preferences -> General -> Startup and Shutdown -> Refresh workspace on startup

Click it in order to have a "fresh" start in eclipse. :)

Version: Eclipse 4.12

于 2020-02-17T20:22:59.223 回答