Java 为什么 eclipse 会创建一个 .settings 目录?

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

Why does eclipse create a .settings directory?

javaeclipse

提问by clamp

i have noticed that eclipse recently creates a .settings directory with 1 file inside and i am wondering if i should add this to version control? SVN?

我注意到 eclipse 最近创建了一个 .settings 目录,里面有 1 个文件,我想知道是否应该将它添加到版本控制中?SVN?

also, is this new? i have been using eclipse for quite a while, but never noticed it.

还有,这是新的吗?我一直在使用eclipse很长一段时间,但从未注意到它。

the contents of the file in the directory is this:

目录中文件的内容是这样的:

#Sun Oct 11 14:57:03 CEST 2009
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.6
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.6

shouldnt these settings be workspace-wide and not project specific?

这些设置不应该是工作区范围的而不是特定于项目的吗?

采纳答案by Alexander Pogrebnyak

This file records project specific settings vs. workspace preferences.

此文件记录项目特定设置与工作区首选项。

I noticed that this file is usually created when you convert a regular Java project to Java EE project.

我注意到这个文件通常是在您将常规 Java 项目转换为 Java EE 项目时创建的。

The only time I would check this file in is when the project's compiler/warning settings are different from the default workspace settings.

我检查这个文件的唯一时间是当项目的编译器/警告设置与默认工作区设置不同时。

This may be the case when some legacy projects cannot be compiled with the latest and greatest java compiler, or when the source code generated by a 3rd party produces a lot of warnings that are benign but pollute your Problemsview.

当一些遗留项目无法使用最新最好的java编译器编译时,或者当第三方生成的源代码产生大量良性但污染您的Problems视图的警告时,可能会出现这种情况。

If you are going to use project specific settings, then definitely check this file in. Otherwise delete it.

如果您打算使用项目特定的设置,那么一定要签入此文件。否则将其删除。

回答by broschb

Those are project specific settings for eclipse. You do not need to include them in svn, as each users eclipse will create these when they checkout project, or they may even use another IDE and not need them. If you are the only one using the project then it won't matter if you include them though.

这些是 eclipse 的项目特定设置。您不需要将它们包含在 svn 中,因为每个 eclipse 用户在签出项目时都会创建这些,或者他们甚至可能使用另一个 IDE 而不需要它们。如果您是唯一一个使用该项目的人,那么即使包含它们也没关系。

回答by fisherja

The .settings folder is used by various plugins to set persistent 'Properties' as opposed to 'Preferences' to specify project specific settings that should be preserved.

.settings 文件夹被各种插件用来设置持久的“属性”而不是“首选项”来指定应该保留的项目特定设置。

This is usually a directory you most definitely want checked into svn/cvs/git etc as it will ensure that all users who check that project out into eclipse use the right project specific settings.

这通常是您最确定要签入 svn/cvs/git 等的目录,因为它将确保所有将该项目签入 eclipse 的用户使用正确的项目特定设置。

In our case we use it to supply a minimum compiler version of 5 since some devs are on Java 5 versus 6 etc but we want things compiled to 5 for our servers. We also use it to enforce some coding standards and auto-formaters which makes version diffs much easier to read.

在我们的例子中,我们使用它来提供 5 的最低编译器版本,因为一些开发人员使用 Java 5 与 6 等,但我们希望为我们的服务器编译为 5。我们还使用它来强制执行一些编码标准和自动格式化程序,这使得版本差异更易于阅读。

In your specific case you selected 'Enable Project Specific Settings' under "Properties->Java Compiler" by right clicking on the project and choosing properties.

在您的特定情况下,您通过右键单击项目并选择属性,在“属性->Java 编译器”下选择了“启用项目特定设置”。