[英]How do I change the default Eclipse Oxygen compiler compliance level from 9 to 1.8 and not have it revert back to 9?
When I open a workspace in Eclipse Oxygen
, the default compiler compliance level is set to 9
. 当我在Eclipse Oxygen
打开工作空间时,默认的编译器合规性级别设置为9
。 I change it in Preferences > Java > Compiler
back to 1.8
and click Apply. 我在Preferences > Java > Compiler
中将其更改回1.8
,然后单击Apply。 It works, until I close Eclipse and reopen it and now it's back to 9
. 它工作,直到我关闭Eclipse并重新打开它,现在它又回到了9
。 How can I make the change stick? 我怎样才能改变这个变化?
Note: I know that /instance/org.eclipse.jdt.core/org.eclipse.jdt.core.compiler.compliance
is set somewhere to 9, but I can't find out where that is. 注意:我知道/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.compiler.compliance
设置为9,但我找不到它的位置。
I cannot replicate your problem of compliance changes not persisting across restarts, but you can manually set them rather than using Eclipse's GUI. 我无法复制合规性更改的问题,而不是在重新启动时保持不变,但您可以手动设置它们而不是使用Eclipse的GUI。 To do that: 要做到这一点:
Locate your preferences file. 找到您的首选项文件。 This is a text file containing many of settings you normally assign in Eclipse using Window > Preferences . 这是一个文本文件,其中包含您通常使用Window> Preferences在Eclipse中分配的许多设置。 The file will be in your workspace directory within the .metadata directory with the following name: 该文件将位于.metadata目录中的workspace目录中,其名称如下:
.metadata.plugins\\org.eclipse.core.runtime.settings\\org.eclipse.jdt.core.prefs .metadata.plugins \\ org.eclipse.core.runtime.settings \\ org.eclipse.jdt.core.prefs
Open the file org.eclipse.jdt.core.prefs in a text editor and edit the following three lines: 在文本编辑器中打开文件org.eclipse.jdt.core.prefs并编辑以下三行:
org.eclipse.jdt.core.compiler.codegen.targetPlatform=9 org.eclipse.jdt.core.compiler.codegen.targetPlatform = 9
org.eclipse.jdt.core.compiler.compliance=9 org.eclipse.jdt.core.compiler.compliance = 9
org.eclipse.jdt.core.compiler.source=9 org.eclipse.jdt.core.compiler.source = 9
This approach worked for me. 这种方法对我有用。 However, even if this approach solves your problem, you could still raise a Bug Report with Eclipse since it should not be necessary to manually edit the preferences file. 但是,即使这种方法解决了您的问题,您仍然可以使用Eclipse引发错误报告,因为不需要手动编辑首选项文件。
My workspace settings were getting over-written by user-specific settings stored in ~/.eclipse/org.eclipse.oomph.setup/setups/user.setup
. 我的工作区设置被存储在~/.eclipse/org.eclipse.oomph.setup/setups/user.setup
的用户特定设置~/.eclipse/org.eclipse.oomph.setup/setups/user.setup
。 Specifically, that file included those leftover setup lines from a previous installation: 具体来说,该文件包含以前安装的剩余设置行:
<setupTask
xsi:type="setup:PreferenceTask"
key="/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.compiler.codegen.targetPlatform"
value="9"/>
<setupTask
xsi:type="setup:PreferenceTask"
key="/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.compiler.compliance"
value="9"/>
<setupTask
xsi:type="setup:PreferenceTask"
key="/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.compiler.source"
value="9"/>
</setupTask>
Solution: Remove the lines above from ~/.eclipse/org.eclipse.oomph.setup/setups/user.setup
. 解决方案:从~/.eclipse/org.eclipse.oomph.setup/setups/user.setup
删除上面的行。
Note: Thanks to @skomisa who helped me figure this out. 注意:感谢@skomisa帮我解决了这个问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.