eclipse 避免“资源与文件系统不同步”

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

Avoiding "resource is out of sync with the filesystem"

eclipse

提问by peter.murray.rust

I develop Java code with Eclipse and regularly get this message:

我使用 Eclipse 开发 Java 代码并经常收到以下消息:

resource is out of sync with the filesystem.

资源与文件系统不同步。

Right-click > Refresh will always clear this.

右键单击 > 刷新将始终清除此项。

But why can't Eclipse refresh automatically when it finds this condition? Are there cases where you want the resource to be out of sync?.

但是为什么Eclipse发现这种情况时不能自动刷新呢?是否存在您希望资源不同步的情况?

If there are such conditions and they don't apply to my work, is there a way of getting Eclipse to refresh automatically when it encounters this state?. (I appreciate that it should refresh as little as it needs to in normal development to increase performance for human developers.)

如果有这样的条件并且它们不适用于我的工作,有没有办法让 Eclipse 在遇到这种状态时自动刷新?。(我很欣赏它应该在正常开发中尽可能少地刷新,以提高人类开发人员的性能。)

UPDATE (2012-06-25): My latest update (Version: Indigo Release Build id: 20110615-0604) no longer shows Preferences - General - Workspace - Refresh Automatically There is an option "Refresh on access" - should I use this?

更新(2012-06-25):我的最新更新(版本:Indigo Release Build id:20110615-0604)不再显示首选项 - 常规 - 工作区 - 自动刷新有一个选项“访问时刷新” - 我应该使用这个吗?

回答by ddewaele

You can enable this in Window - Preferences - General - Workspace - Refresh Automatically (called Refresh using native hooks or pollingin newer builds)

您可以在 Window - Preferences - General - Workspace - Refresh Automatically 中启用此功能(使用本机钩子调用刷新或在较新版本中进行轮询

Eclipse Preferences "Refresh using native hooks or polling" - Screenshot

Eclipse 首选项“使用本机钩子或轮询刷新” - 屏幕截图

The only reason I can think why this isn't enabled by default is performance related.

我认为默认情况下未启用此功能的唯一原因与性能有关。

For example, refreshing source folders automatically might trigger a build of the workspace. Perhaps some people want more control over this.

例如,自动刷新源文件夹可能会触发工作区的构建。也许有些人希望对此进行更多控制。

There is also an article on the Eclipse siteregarding auto refresh.

Eclipse 站点上还有一篇关于自动刷新的文章。

Basically, there is no external trigger that notifies Eclipse of files changed outside the workspace. Rather a background thread is used by Eclipse to monitor file changes that can possibly lead to performance issues with large workspaces.

基本上,没有外部触发器通知 Eclipse 工作区外的文件更改。相反,Eclipse 使用后台线程来监视可能导致大型工作区性能问题的文件更改。

回答by bhejaFry

Just right click on the file or on the project and click Refresh. The error will vanish. I also faced the same issue and it worked for me.

只需右键单击文件或项目,然后单击刷新。错误将消失。我也遇到了同样的问题,它对我有用。

回答by hitesh141

enter image description hereWindow -> Preferences -> General -> Workspace

在此处输入图片说明窗口 -> 首选项 -> 常规 -> 工作区

回答by zhihong

For the new Indigo version, the Preferences change to "Refresh on access", and with a detail explanation : Automatically refresh external workspace changes on access via the workspace.

对于新的 Indigo 版本,首选项更改为“访问时刷新”,并附有详细说明:通过工作区访问时自动刷新外部工作区更改。

As “resource is out of sync with the filesystem” this problem happens when I use external workspace, so after I select this option, problem solved.

由于“资源与文件系统不同步”,当我使用外部工作区时会出现此问题,因此选择此选项后,问题解决了。

回答by Jeff Berkowitz

This happens to me all the time.

这一直发生在我身上。

Go to the error log, find the exception, and open a few levels until you can see something more like a root cause. Does it says "Resource is out of sync with the file system" ?

转到错误日志,找到异常,然后打开几个级别,直到您可以看到更像是根本原因的内容。它是否说“资源与文件系统不同步”?

When renaming packages, of course, Eclipse has to move files around in the file system. Apparently what happens is that it later discovers that something it thinks it needs to clean up has been renamed, can't find it, throws an exception.

当然,在重命名包时,Eclipse 必须在文件系统中移动文件。显然发生的事情是它后来发现它认为需要清理的东西已被重命名,找不到它,抛出异常。

There are a couple of things you might try. First, go to Window: Preferences, Workspace, and enable "Refresh Automatically". In theory this should fix the problem, but for me, it didn't.

您可以尝试以下几种方法。首先,转到窗口:首选项、工作区,然后启用“自动刷新”。理论上这应该可以解决问题,但对我来说,它没有。

Second, if you are doing a large refactoring with subpackages, do the subpackages one at a time, from the bottom up, and explicitly refresh with the file system after each subpackage is renamed.

其次,如果您正在对子包进行大型重构,则一次一个地进行,自下而上,并在每个子包重命名后显式刷新文件系统。

Third, just ignore the error: when the error dialog comes up, click Abort to preserve the partial change, instead of rolling it back. Try it again, and again, and you may find you can get through the entire operation using multiple retries.

第三,忽略错误:当错误对话框出现时,单击 Abort 以保留部分更改,而不是将其回滚。一次又一次地尝试,您可能会发现可以通过多次重试来完成整个操作。

回答by TaninDirect

If this occurs trying to delete a folder (on *nix) and Refresh does not help, open a terminal and look for a symlink below the folder you are trying to delete and remove this manually. This solved my issues.

如果尝试删除文件夹(在 *nix 上)发生这种情况并且刷新没有帮助,请打开终端并在您尝试删除的文件夹下方查找符号链接并手动删除它。这解决了我的问题。

回答by wathson

A little hint. The message often appears during rename operation. The quick workaround for me is pressing Ctrl-Y(redo shortcut) after message confirmation. It works only if the renaming affects a single file.

一点提示。该消息经常在重命名操作期间出现。我的快速解决方法是Ctrl-Y在消息确认后按(重做快捷方式)。仅当重命名影响单个文件时才有效。

回答by user3583015

When you open an Eclipse workspace from within a clearcase view and try to rename the project, you will often get the pop-up warning ... “Resource ‘project' is out of sync with the file system”. If refreshing the project does not fix the problem, then do the following workaround: a. Open workspace WITHOUT being in a view b. Select the project in Project Explorer c. ClearCase -> Associate Project (project should now look like project [] ) d. Right click project -> Refresh (vob sub-folders should now be empty) e. Right click project -> Rename ... f. Enter New name

当您从 clearcase 视图中打开 Eclipse 工作区并尝试重命名项目时,您经常会收到弹出警告...“资源'项目'与文件系统不同步”。如果刷新项目不能解决问题,请执行以下解决方法:不在视图中的情况下打开工作区 b. 在 Project Explorer 中选择项目 c. ClearCase -> Associate Project(项目现在应该看起来像 project [] ) d. 右键单击项目 -> 刷新(vob 子文件夹现在应该是空的) e. 右键单击项目-> 重命名... f。输入新名称

Now you can close the workspace, reopen it in a view and refresh the project. You may also dissociate the project if you prefer the project not to be associated with the vob.

现在您可以关闭工作区,在视图中重新打开它并刷新项目。如果您不希望项目与 vob 关联,您也可以取消关联该项目。

回答by BERGUIGA Mohamed Amine

If you are a regular Eclipse user than you might have got this error many times. The error simply says, “you've made changes in files in your workspace from outside eclipse”. The simplest solution would be to select the project and press F5 (Right click -> Refresh).

如果您是 Eclipse 的普通用户,那么您可能会多次遇到此错误。错误只是说,“您已经从 eclipse 外部对工作区中的文件进行了更改”。最简单的解决方案是选择项目并按 F5(右键单击 -> 刷新)。

if you need more explanation you can read from this web site

如果你需要更多的解释,你可以从这个网站上阅读

回答by nitinsh99

I was not able to resolve this error by either refresh or by turning on "native polling" workspace feature. Turned out my project was also opened in two instances of eclipse. Once I closed the other instance, the error went away. So make sure your project is only opened at one place if you are seeing this error.

我无法通过刷新或打开“本机轮询”工作区功能来解决此错误。原来我的项目也是在两个eclipse实例中打开的。一旦我关闭了另一个实例,错误就消失了。因此,如果您看到此错误,请确保您的项目仅在一处打开。