Mar*_*cký 3 java osgi maven apache-felix
尝试启动捆绑包时出现此错误:
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)))]
Run Code Online (Sandbox Code Playgroud)
我的 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>
Run Code Online (Sandbox Code Playgroud)
代码:
门面.java:
package com.example;
public interface Facade {}
Run Code Online (Sandbox Code Playgroud)
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;
}
}
Run Code Online (Sandbox Code Playgroud)
我究竟做错了什么?
谢谢
您的包包含一个声明性服务组件——FacadeLocator来自您的代码。这意味着您依赖于实现声明式服务的“扩展器”包。您需要将该捆绑包与您自己的捆绑包一起部署才能使其正常工作。
来自 Apache Felix 的 DS 实现包有名字org.apache.felix.scr,可以从 Maven Central下载。
你看到的错误信息可以解码如下。您在osgi.extender命名空间(类似于 DS 的扩展程序的命名空间)中缺少一个要求。您需要的特定扩展程序是osgi.component1.3 或更高版本。maven-bundle-plugin 在你的包的 META-INF/MANIFEST.MF 中生成了这个需求,因为它看到你的包中有一个组件。每当一个包有需求时,就必须有另一个提供匹配功能的包。在这种情况下,该捆绑包是org.apache.felix.scr。
| 归档时间: |
|
| 查看次数: |
1871 次 |
| 最近记录: |