【问题标题】:Setting an attribute to launch configuration in eclipse设置属性以在 Eclipse 中启动配置
【发布时间】:2013-04-05 10:35:38
【问题描述】:

eclispe3.7 中的一个应用程序,我想在每次启动时为启动配置设置一个属性。我正在使用以下命令设置属性,但是在获取属性时,它只显示默认属性值。

launch.getLaunchConfiguration().getWorkingCopy().setAttribute(IGDBLaunchConfigurationConstants.ATTR_PORT, value);

在另一个类上,使用以下代码从第一个类启动:

launch.getLaunchConfiguration()..getWorkingCopy().getAttributes();

为什么不能设置属性?请帮帮我...

【问题讨论】:

    标签: eclipse configuration attributes launch


    【解决方案1】:

    我怀疑问题在于每次调用 getWorkingCopy() 都会得到不同的工作副本。如果您在调试器中检查工作副本对象的 Java ID,那么您将能够确定。

    希望这会有所帮助, 托马斯

    【讨论】:

      【解决方案2】:

      当你使用 getWorkingCopy() 时,你会得到原始状态的副本,但你还需要使用 doSave()。

      ILaunchConfigurationWorkingCopy launchCopy = launch.getWorkingCopy();
      launchCopy.setAttribute(IGDBLaunchConfigurationConstants.ATTR_PORT, value);
      launch = launchCopy.doSave();
      

      你可以在这里阅读,它是如何工作的:http://comments.gmane.org/gmane.comp.ide.eclipse.platform.debug.devel/240

      【讨论】:

        猜你喜欢
        • 2023-03-22
        • 2011-09-28
        • 2012-11-25
        • 2012-10-07
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多