无法在 Eclipse 中保存项目首选项

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

Can't save project preferences in Eclipse

eclipseidesettings

提问by Real Red.

All I am trying to do is to set the Java compiler for my project as 5.0. It is 1.4 by default. When I try to save by pressing OK button I get the following error.

我想要做的就是将我的项目的 Java 编译器设置为 5.0。默认为 1.4。当我尝试按 OK 按钮保存时,出现以下错误。

Preferences Save Failed:

首选项保存失败:

Reason: Exception Occured while saving project preferences: /com.myproj.reqmanager.ui/.settings/org.eclipse.jdt.ui.prefs.

原因:保存项目首选项时发生异常:/com.myproj.reqmanager.ui/.settings/org.eclipse.jdt.ui.prefs。

I never got this error earlier. I mean I have imported this project before and saved preference settings without any problem. Out of nowhere I am getting this problem now.

我以前从来没有遇到过这个错误。我的意思是我之前已经导入了这个项目并保存了首选项设置,没有任何问题。我现在突然遇到了这个问题。

回答by VonC

If you follow this thread, this can be:

如果您遵循此线程,则可以是:

  • because of the use of Eclipse with a workspace on a network drive (not necessarily your case, but worth mentioning just in case)
  • because the file is somehow locked (either by another process or by a Version Control System with pessimistic locking). See also bug 130266:
  • 因为 Eclipse 与网络驱动器上的工作区一起使用(不一定是您的情况,但值得一提以防万一)
  • 因为文件以某种方式被锁定(被另一个进程或带有悲观锁定的版本控制系统)。另见错误 130266

Read-only project files come up a lot when dealing with source control systems (like Perforce) that make the local files read-only until they are "checked out".

在处理使本地文件只读直到它们被“签出”的源代码控制系统(如 Perforce)时,只读项目文件会出现很多。

回答by Njol

Like Liam I store my project on Dropbox and use it on two different machines and also got the same error. A simple refresh (select the project and press F5, or rightclick on the project and choose Refresh) did the trick for me, as the resource was out of sync. This is usually displayed (e.g. in the editor when trying to edit a source file), but in the case of preferences you'll have to find that message in eclipse's log:

像 Liam 一样,我将我的项目存储在 Dropbox 上并在两台不同的机器上使用它,但也遇到了同样的错误。一个简单的刷新(选择项目并按 F5,或右键单击项目并选择刷新)对我有用,因为资源不同步。这通常会显示(例如,在尝试编辑源文件时在编辑器中),但在首选项的情况下,您必须在 eclipse 的日志中找到该消息:

!MESSAGE Exception occurred while saving project preferences: /Utils/.settings/org.eclipse.jdt.core.prefs.
!STACK 1
org.eclipse.core.internal.resources.ResourceException: Resource is out of sync with the file system: '/Utils/.settings/org.eclipse.jdt.core.prefs'.

This might actually be the issue for both of you, as any external modification to a project will cause this out of sync error, and creating a new workspace or using another eclipse version likely purges eclipse's cache, resulting in an automatic refresh.

这实际上可能是你们双方的问题,因为对项目的任何外部修改都会导致这种不同步错误,并且创建新的工作区或使用另一个 eclipse 版本可能会清除 eclipse 的缓存,从而导致自动刷新。

回答by Indivara

Five years later and this still occurs. In my case I moved the .settingsfolder, saved again (.settingsis created automatically) and merged the files manually.

五年后,这种情况仍然发生。在我的情况下,我移动了.settings文件夹,再次保存(.settings自动创建)并手动合并文件。

Happens on Android Developer Tools Build: v22.6.2.

发生在 Android Developer Tools Build: v22.6.2 上。

回答by Tom

Check the project's Properties -> Java Compiler, and make sure the 'Compiler compliance level' is 1.8 or 1.7 instead of 1.4.

检查项目的Properties -> Java Compiler,并确保“ Compiler compliance level”是 1.8 或 1.7 而不是 1.4。

If this still fails to remove the error, deleting the .settingsfolder certainly works.

如果这仍然无法消除错误,删除.settings文件夹当然有效。

回答by Liam O Donnell

I had this problem also. I had used two versions of eclipse, one on my home machine (juno) and one on my work machine (indigo). Both shared the same folder using a Dropbox folder. All worked fine until I wanted to make some editor style changes, the settings would not save.

我也有这个问题。我使用过两个版本的 eclipse,一个在我的家用机器 (juno) 上,另一个在我的工作机器 (indigo) 上。两者都使用 Dropbox 文件夹共享同一个文件夹。一切正常,直到我想进行一些编辑器样式更改,设置不会保存。

The solution in my case was to update the indigo version to juno on my work machine.

我的解决方案是在我的工作机器上将 Indigo 版本更新为 juno。