felix maven-bundle-plugin 错误 (&(osgi.wiring.package=com.abc)(version>=xx.0.0)(!(version>=yy.0.0)

Ahm*_*emi 0 osgi apache-felix maven-bundle-plugin

我使用Apache Felix来实现osgi包并将其用作嵌入式Felix框架来调用boundle

这是我的 Maven 插件来构建 MANIFEST.MF :

<plugin>
            <groupId>org.apache.felix</groupId>
            <artifactId>maven-bundle-plugin</artifactId>
            <version>3.5.0</version>
            <extensions>true</extensions>
            <configuration>
                <instructions>
                    <Embed-Dependency>*;scope=compile|runtime</Embed-Dependency>
                    <Bundle-Activator>a.b.c.osgi.activator.Activator</Bundle-Activator>
                </instructions>
            </configuration>
        </plugin>
Run Code Online (Sandbox Code Playgroud)

我构建项目,然后在嵌入的 felix 中使用 jar 文件,如下所示

BundleContext bundleContext = f.getBundleContext();
    Bundle bundle = bundleContext.installBundle(
            "file:/home/eclipse_workSpace/my-module/target/abc-1.1.0.jar");)

    String bName = bundle.getLocation();
    bundle.getRegisteredServices();
    bundle.getState();

    /* Bundle[] bls = bundleContext.getBundles(); */

    System.out.println("starting bundle " + bName);
    bundle.start();
Run Code Online (Sandbox Code Playgroud)

当我开始 Boundle 时,我遇到了这个异常

线程“main”中的异常 org.osgi.framework.BundleException:无法解析 abc [1](R 1.0):缺少要求 [abc [1](R 1.0)] osgi.wiring.package;(&(osgi.wiring.package=com.google.common.base)(version>=21.0.0)(!(version>=22.0.0))) 未解决的要求:[[abc [1](R 1.0) ] osgi.wiring.package;(&(osgi.wiring.package=com.google.common.base)(版本>=21.0.0)(!(版本>=22.0.0)))]

我应该怎么做才能解决这个问题?

Nei*_*ett 5

此错误消息意味着您的捆绑包依赖于 Google Guava 版本 21。具体来说这一行:

missing requirement [a.b.c [1](R 1.0)] osgi.wiring.package; (&(osgi.wiring.package=com.google.common.base)(version>=21.0.0)(!(version>=22.0.0)))
Run Code Online (Sandbox Code Playgroud)

...意味着您的捆绑包“abc”导入了com.google.common.base版本大于或等于 21 且不大于或等于 22 的包。由于您的捆绑包导入了此包,因此其中必须有另一个捆绑包导出包的 OSGi 框架。

解决方案是确保 Guava 21 安装到您的 OSGi 框架中。