gpt4 book ai didi

java - Eclipse 插件包卡在启动状态

转载 作者:搜寻专家 更新时间:2023-10-31 20:21:46 24 4
gpt4 key购买 nike

我使用 Eclipse 创建了一个新的插件项目,它为我创建了一个默认的 Activator。在调试(作为 Eclipse 应用程序运行)时,我注意到未调用此激活器的 start()stop() 方法。

正在关注 the guide on what to do when your bundle isn't visible in Eclipse我偶然发现了以下结果。

  • 使用 ss 命令,我可以看到我的包已列出。
  • 我的 bundle 的状态是“Starting” '

The bundle is in the process of starting. A bundle is in the STARTING state when its start method is active. A bundle must be in this state when the bundle's BundleActivator.start(BundleContext) is called. If the BundleActivator.start method completes without exception, then the bundle has successfully started and must move to the ACTIVE state.

放置在 start 方法第一行的断点不会被命中。 System.out.println 也没有出现在控制台中。什么会导致 start 方法未被调用,从而导致状态停留在 STARTING

最佳答案

以下内容并未解决 OSGi 控制台将插件报告为 STARTING 的事实,但这是一种让我的插件在 Eclipse 启动后立即启动的方法。

作为Chris Gerken points out in a comment ,启动代码仅在您尝试使用其中一个插件扩展时运行。

使用 org.eclipse.ui.startup 扩展你可以注册一个想要在启动时激活的插件。可以使用 list 编辑器进行设置。

  1. 添加org.eclipse.ui作为“依赖项”选项卡中的依赖项。
  2. 在“扩展”选项卡中添加启动扩展 (org.eclipse.ui.startup)。
  3. 在“Extension Element Details”下面提供了一个实现了org.eclipse.ui.IStartup的类.

startup extension

任务管理器.java

public class TaskManager implements IStartup
{
@Override
public void earlyStartup()
{
// This will get called when Eclipse is started,
// after the GUI has been initialized.
}
}

关于java - Eclipse 插件包卡在启动状态,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13799093/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com