首页 > 解决方案 > 未解决的需求:Require-Bundle: org.apache.lucene

问题描述

我对 Eclipse 很陌生。我尝试为此设置 Eclipse 插件开发环境: https ://github.com/ajermakovics/eclipse-instasearch

我按照项目根目录中的使用 Maven 构建指令进行操作:

(in "eclipse-instasearch" folder)
mvn install

Use File -> Import -> Existing Projects to import all instasearch projects ("eclipse-instasearch" folder)
To run or debug right click on 'instasearch' project and select Run As -> Eclipse Application

在“MANIFEST.MF”中它抱怨“捆绑'org.apache.lucene'无法解决”

Run As Eclipse Application 将在控制台中显示此异常:

org.osgi.framework.BundleException: Could not resolve module: it.unibz.instasearch [19]
  Unresolved requirement: Require-Bundle: org.apache.lucene; bundle-version="[2.9.1,2.9.2]"

    at org.eclipse.osgi.container.Module.start(Module.java:462)
    at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel$2.run(ModuleContainer.java:1844)
    at org.eclipse.osgi.internal.framework.EquinoxContainerAdaptor$1$1.execute(EquinoxContainerAdaptor.java:136)
    at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1837)
    at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1778)
    at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.doContainerStartLevel(ModuleContainer.java:1742)
    at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1664)
    at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1)
    at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:234)
    at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:345)
log4j:WARN No appenders could be found for logger (org.eclipse.jgit.internal.storage.file.FileSnapshot).
log4j:WARN Please initialize the log4j system properly.

插件无法加载,无法在菜单中看到。

我还尝试了“从文件系统打开项目”来打开根文件夹,这样上下文菜单中就没有“运行为 Eclipse 应用程序”选项。

我一定错过了什么,有人可以指导我吗?

标签: eclipsemaven

解决方案


默认情况下,Eclipse 使用自己的环境(即安装的插件)来解决插件项目的依赖关系。正如@greg-449 在评论中所说,Lucene 默认不再包含在内,这就是构建失败的原因。你基本上有两种选择来解决这个问题:

  1. 将 Lucene 插件添加到环境中(可以在 Orbit 的更新站点中找到:https ://download.eclipse.org/tools/orbit/downloads/ )
  2. 将 Lucene 的 JAR 文件包装在 Eclipse 插件中:如何从 Java 库(JAR 文件)创建 Eclipse 插件并将生成的插件添加到存储库中。

权衡是在 Eclipse 插件中包装 JAR 文件需要更多的工作(创建和维护),而通过 Orbit 将 Lucene 添加到环境中会减慢构建速度。而且,“将 Lucene 添加到环境中”目前的意思是“在 Eclipse 中安装插件”,这只是每个开发人员的解决方案。如果您打算维护插件,我建议您考虑改用目标平台:这将使环境与平台无关(我在这个答案中写了一些关于此的内容)。

最后,似乎eclipse-instasearch的一个分支已经解决了这个问题。您可以通过浏览最新的 GitHub 问题轻松找到它。


推荐阅读