当我试图启动一个包时,我得到了这个错误:
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>代码:
Facade.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;
}
}我做错了什么?
谢谢
发布于 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。
发布于 2022-02-04 13:15:10
在karaf中,使用此cmd特性安装功能声明性服务支持:安装scr
https://stackoverflow.com/questions/54020799
复制相似问题