【问题标题】:Where does Eclipse store preferences?Eclipse 在哪里存储首选项?
【发布时间】:2013-06-30 04:45:52
【问题描述】:

当我在如下屏幕截图所示的窗口中更改设置时,这些设置实际存储在哪里?

奖励:有什么方法可以使用 Java、Eclipse RCP 等以编程方式访问设置?

谢谢!

【问题讨论】:

  • 检查您的 workspace 文件夹。有这个 properties.properties 文件可以解决你的好奇心,还有一个 .metadata 文件夹。

标签: java eclipse formatting eclipse-rcp settings


【解决方案1】:

来源:Eclipse wiki

如果您想将首选项从一个版本保留到另一个版本,请使用文件/导出/首选项导出它们。

首选项存储在不同的地方(这适用于 Eclipse 3.1)

对于每个安装(但对于多用户安装,这可能会有所不同),存储在以下文件中: <eclipse_home>/eclipse/configuration/.settings/

每个插件通常有一个文件,带有 prefs 扩展名。请注意,很少有插件使用安装范围的首选项。

对于每个工作区,在 <workspace>/.metadata/.plugins/org.eclipse.core.runtime/.settings 中存储的文件中。

每个插件通常有一个文件,带有 prefs 扩展名。 对于每个项目 -- 用于项目级设置 -- 存储在项目文件夹的 .settings 子目录中的文件中。

Here's使用java代码访问首选项的文章。

【讨论】:

  • 那篇文章是 2002 年的,现在还有用吗?
  • 在mac上,类型路径一在:/Applications/Eclipse.app/Contents/Eclipse/configuration/.settings
  • 如果阅读本文的人有足够的代表进行 1 个字符的编辑,那么现在在第二个链接中有一个 https 版本的 URL。
【解决方案2】:

首选项存储在工作区.metadata/.plugins/org.eclipse.core.runtime/.settings 的首选项文件中。每个贡献首选项的插件都有一个 prefs 文件。

通过IPreferencesService 以编程方式访问整个首选项,您可以使用Platform.getPreferencesService() 获得。

您可以在Runtime preferences Eclipse 帮助页面中找到有关如何使用它们的更多信息和示例。

【讨论】:

    【解决方案3】:

    搜索它:

    在 Eclipse 中更改一些设置然后运行:

    find ~  -type f -mmin -5 | grep "\.settings"
    

    这将发现最近 5 分钟内修改过的文件。

    我在workspace,字面意思是...

    ~/workspace/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.workbench.prefs
    

    【讨论】:

    • 啊!这是找到变化的好方法 - 谢谢
    【解决方案4】:

    你可以在Lars Vogelsaneclipse项目中看到大部分相关的eclipse设置(主要针对JDT)。

    查看vogellacompany/com.vogella.saneclipse repo,它将调整和微调以下设置:

    com.vogella.saneclipse.preferences/.settings/org.eclipse.jdt.core.prefs
    com.vogella.saneclipse.preferences/.settings/org.eclipse.core.runtime.prefs
    com.vogella.saneclipse.preferences/.settings/org.eclipse.core.resources.prefs
    com.vogella.saneclipse.templates/.settings/org.eclipse.jdt.core.prefs
    com.vogella.saneclipse.fileextensions/.settings/org.eclipse.jdt.core.prefs
    com.vogella.saneclipse.fileextensions/.settings/org.eclipse.pde.core.prefs
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-09-03
      • 2011-06-24
      • 1970-01-01
      • 2014-12-11
      • 2010-10-15
      • 1970-01-01
      相关资源
      最近更新 更多