首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Apache错误:缺少需求osgi.extender

Apache错误:缺少需求osgi.extender
EN

Stack Overflow用户
提问于 2019-01-03 10:47:41
回答 2查看 2.9K关注 0票数 3

当我试图启动一个包时,我得到了这个错误:

代码语言:javascript
复制
org.osgi.framework.BundleException:
  Unable to resolve com.example.test [7](R 7.0):
    missing requirement [com.example.test [7](R 7.0)] osgi.extender; (&(osgi.extender=osgi.component)(version>=1.3.0)(!(version>=2.0.0)))
  Unresolved requirements:
    [[com.example.test [7](R 7.0)] osgi.extender; (&(osgi.extender=osgi.component)(version>=1.3.0)(!(version>=2.0.0)))]

我的pom.xml:

代码语言:javascript
复制
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.example</groupId>
    <artifactId>test</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>bundle</packaging>

    <dependencies>
        <dependency>
            <groupId>org.osgi</groupId>
            <artifactId>org.osgi.core</artifactId>
            <version>6.0.0</version>
        </dependency>

        <dependency>
            <groupId>org.osgi</groupId>
            <artifactId>org.osgi.service.component.annotations</artifactId>
            <version>1.4.0</version>
        </dependency>
    </dependencies>

    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.felix</groupId>
                    <artifactId>maven-bundle-plugin</artifactId>
                    <version>4.0.0</version>
                    <extensions>true</extensions>
                </plugin>
            </plugins>
        </pluginManagement>

        <plugins>
            <plugin>
                <groupId>org.apache.felix</groupId>
                <artifactId>maven-bundle-plugin</artifactId>
                <configuration>
                    <instructions>
                        <Export-Package>com.example</Export-Package>
                    </instructions>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

代码:

Facade.java:

代码语言:javascript
复制
package com.example;
public interface Facade {}

FacadeLocator.java:

代码语言:javascript
复制
package com.example;

import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Reference;

@Component
public class FacadeLocator {
    public static Facade facade;

    @Reference
    public void setFacade(Facade facade) {
        FacadeLocator.facade = facade;
    }
}

我做错了什么?

谢谢

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2019-01-03 13:34:43

您的包包含一个声明性服务组件--代码中的FacadeLocator。这意味着您依赖于实现声明性服务的“扩展程序”包。您需要将该包与您自己的包一起部署,这样它才能正常工作。

Apache的DS实现包名为org.apache.felix.scr,可以下载来自Maven Central

您看到的错误消息可以按照以下方式解码。在osgi.extender名称空间中缺少一个需求(扩展程序的名称空间类似于DS)。您需要的特定扩展程序是osgi.component,版本1.3或更高。maven- bundle插件在包的META/MANIFEST.MF中生成了这个需求,因为它看到您的包中有一个组件。当包有需求时,必须有另一个包提供匹配功能。在本例中,该包是org.apache.felix.scr

票数 7
EN

Stack Overflow用户

发布于 2022-02-04 13:15:10

在karaf中,使用此cmd特性安装功能声明性服务支持:安装scr

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/54020799

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档