Eclipse 可以自动刷新资源吗?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1212633/
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
Can Eclipse refresh resources automatically?
提问by DNS
Eclipse (3.4.2 with PyDev) deals with out-of-sync resources (files that have been edited outside of the IDE) differently from other IDEs that I've used, where only resources with editors open are considered out-of-sync. In Eclipse, any resource can go out of sync.
Eclipse(3.4.2 with PyDev)处理不同步资源(已在 IDE 外部编辑的文件)与我使用过的其他 IDE 不同,其中只有打开编辑器的资源被认为是不同步的. 在 Eclipse 中,任何资源都可能不同步。
This means that when I perform a search after any file has changed outside of Eclipse, I get an error dialog telling me that files are out of sync, even if they have no open editors. As far as I can tell, there is no global refresh command, so I'm forced to read the project names (I have several projects) in the error dialog, and do a right-click + refresh for each of them.
这意味着当我在 Eclipse 之外更改任何文件后执行搜索时,我会收到一个错误对话框,告诉我文件不同步,即使它们没有打开的编辑器。据我所知,没有全局刷新命令,所以我被迫在错误对话框中读取项目名称(我有几个项目),并对每个项目进行右键单击 + 刷新。
I've checked the Refresh Automatically
setting in Settings > General > Workspace
, but this has no effect. Is there any way to get Eclipse to always just load non-active resources from disk?
我已经检查了 中的Refresh Automatically
设置Settings > General > Workspace
,但这没有效果。有什么方法可以让 Eclipse 始终从磁盘加载非活动资源?
回答by James Blackburn
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.
此问题将在 Eclipse 3.7 (Indigo) 中修复。尽管“自动刷新”最终确实使资源恢复同步,但刷新挂钩仅适用于 Windows,因此在 Linux 和 Mac OS 上,它必须定期轮询文件系统。
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.
从 3.7 开始,有一个新的偏好Settings > General > Workspace > Refresh On Access
(又名轻量级刷新)。此首选项会导致 Eclipse 在发现资源“不同步”时自动刷新资源。打开、读取或搜索文件时,它将防止发生不同步错误。
See also: https://bugs.eclipse.org/303517
回答by Thomas Owens
I think if you click on the project node in the Project Explorer and press F5 or right click and select Refresh, all resources for that project will be refreshed. Also, if you CTRL+click on multiple projects, you should be able to refresh multiple projects at the same time.
我想如果你在 Project Explorer 中点击项目节点并按 F5 或右键单击并选择刷新,该项目的所有资源都会被刷新。此外,如果您按住 CTRL 键并单击多个项目,您应该能够同时刷新多个项目。
A single click on a project, a CTRL+A to select everything, and an F5 should do exactly what you need - refresh everything.
单击一个项目,按 CTRL+A 选择所有内容,然后按 F5 即可完全满足您的需要 - 刷新所有内容。
I'll have to test this when I get the chance, but I believe this is how I overcame similar problems in the past.
当我有机会时,我将不得不对此进行测试,但我相信这是我过去克服类似问题的方式。
I've noticed that this answer routinely is getting down voted. I'd like to point out that the question refers to a specific version of Eclipse: 3.4.2. There was actually no automatic method to refresh out-of-sync resources until version 3.7 Indigo of Eclipse, as mentioned in James Blackburn's answer. The method described in this answer is the only method to achieve this in version 3.4.2 (and any other version before 3.7 Indigo).
我注意到这个答案经常被否决。我想指出这个问题是指 Eclipse 的特定版本:3.4.2。在Eclipse 的 3.7 Indigo 版本之前,实际上没有自动刷新不同步资源的方法,如James Blackburn 的回答中所述。此答案中描述的方法是在 3.4.2 版(以及 3.7 Indigo 之前的任何其他版本)中实现此目的的唯一方法。
回答by DON
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.
不同步问题在 Eclipse IDE 中很常见,因此您必须选中此选项 windows -> 首选项 -> 工作区 -> 使用本机挂钩或轮询刷新。
回答by Michael Borgwardt
There is a global refresh - have nothing (or everything) selected in the package explorer and press F5 (or right-click on empty space and select Refresh). Of course, this could take rather long if you have large projects.
有一个全局刷新 - 在包资源管理器中没有选择任何(或所有)并按 F5(或右键单击空白区域并选择刷新)。当然,如果您有大型项目,这可能需要相当长的时间。
回答by user466206
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.
Eclipse Helios 在 Preferences > General > Workspace 中拥有一个内置的刷新功能。它与您禁用自动构建的位置相同。选择自动刷新。具有相同功能的插件是 Andrei Loskutov 的 Filesync 插件。更新站点地址为:http: //andrei.gmxhome.de/eclipse/。在安装过程中,选择 Eclipse 3.5-3.7 plugins > FileSync。
回答by bronsted
Given that Java 7 has an api for filesystem hooks, one would think that refresh could be handled better in Eclipse.
鉴于 Java 7 有一个用于文件系统挂钩的 api,人们会认为在 Eclipse 中可以更好地处理刷新。
Edit: Actually, there is a plugin that uses this mechanism: https://github.com/psxpaul/EclipseJava7Refresher
编辑:实际上,有一个使用这种机制的插件:https: //github.com/psxpaul/EclipseJava7Refresher
回答by Gediminas Aleknavi?ius
The global refresh actually exists in plain Eclipse without any plugins and without selecting every project in your workspace.
全局刷新实际上存在于纯 Eclipse 中,没有任何插件,也没有选择工作区中的每个项目。
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.
基本上,您需要取消选择项目资源管理器中的所有内容并按 F5。为此,请在项目资源管理器中按住 Ctrl 键并单击所选资源并按 F5。
回答by Gediminas Aleknavi?ius
Perhaps you should add a feature request on the eclipse site:
也许您应该在 eclipse 站点上添加一个功能请求:
https://bugs.eclipse.org/bugs/
https://bugs.eclipse.org/bugs/
I think it would be a great idea to add a preference for automatically refreshing out of date resources.
我认为添加自动刷新过时资源的首选项是个好主意。
回答by Karol
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.
Eclipse 中确实缺少全局刷新。如果您的选择中包含已关闭的项目,则上述选择所有项目然后运行刷新(例如 F5)的过程将不起作用。这意味着,如果您像我一样关闭了许多项目中的 1/2,您会发现自己手动按住 Ctrl 键单击浏览您的数十个项目。这是相当痛苦的。我希望 Eclipse 会简单地忽略已关闭的项目。
回答by NateS
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.
我设法通过创建一个执行空白批处理文件的新“外部工具”运行配置来解决这个问题。在运行配置中,您可以让它在完成后刷新工作区。然后我使用 Practical Macro 创建了一个宏,它 1) 执行最后一个外部工具运行配置(刷新工作区),然后 2)执行最后一个调试运行配置(运行我的应用程序)。如果取消选中“分配控制台”,则完成的外部工具条目将不会显示在调试窗口中。