gpt4 book ai didi

java - Apache Felix OSGi 错误 : missing requirement osgi. 扩展程序

转载 作者:行者123 更新时间:2023-12-01 17:47:01 25 4
gpt4 key购买 nike

我在尝试启动 bundle 时收到此错误:

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:

<?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>

代码:

门面.java:

package com.example;
public interface Facade {}

FacadeLocator.java:

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;
}
}

我做错了什么?

谢谢

最佳答案

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

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

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

关于java - Apache Felix OSGi 错误 : missing requirement osgi. 扩展程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54020799/

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